home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-06-03 | 88.9 KB | 3,926 lines |
- *** 1.74 1992/04/19 16:02:45
- --- Changelo 1992/06/03 14:47:44
- ***************
- *** 3067,3069 ****
- --- 3067,3171 ----
- find stuff in such PATH's (like when using findfile).
-
- ---------------------------- Patchlevel 80 ---------------------------
- +
- + bcopy.s:: michal
- + I looked at this new bcopy from the latest update and decided to check
- + if it is faster only theoretically or maybe also in practice. Reason
- + beeing that my friend claimed that he tried a similar code on TT and
- + after much coding it was actually slower. So I got curious. Well, at
- + least on my Mega it is faster. For some cases significantly so.
- + Although nearly twice as big as the previous one. Still I found that
- + a small change speeds it up BUT in my experiments only for misaligned
- + data. In such situations I got up to 10% shorter times for a little
- + bit longer data (break-even seems to be around 25 bytes; for
- + smaller sizes the modified code is a tad slower but differences in timing
- + are truly neglibible). I still wonder why a similar change in a loop
- + control for aligned data did not bring any real speed variations.
- +
- + Another surprise - two tests with branches for the last three
- + bytes are actually better than a tight dbra loop. This may look
- + quite a bit different on a small instruction cache of 68020.
- +
- + [ jrb: yes, also it will be interesting to see the difference on
- + 68k's with loop-mode (is the 010 the only one??)].
- +
- + localtim.c:: ++jrb
- + rename dst to _dst and make it non-static. timeoday.c uses it.
- +
- + ctype.c:: ++jrb
- + break out toupper(), tolower() into seperate file so that
- + users can re-define these and yet pull in ctype stuff, whout
- + clashing. (me2 does this).
- +
- + toxxx.c:: +=jrb
- + new file comtaining toupper()/tolower()
- +
- + mincl:: ++jrb
- + add target for toxxx.o
- +
- + mintbind.h:: ++jrb
- + add def for Psigpause() per MiNT 0.95 pl 1
- +
- + osbind.h: ers
- + Bconmap should be XBIOS call 0x2c, *not* 0x2b.
- + 0x2b is DMAwrite. There's obviously a potential for serious
- + lossage here :-(. (mntlib has the same bug)
- +
- + doprnt.c:: ers
- + -- conditionalize prototypes so Sozobon can compile this
- + -- use "+Inf", "-Inf", "NaN" instead of " Infinity ",
- + " -Infinity ", and " Not A Number ". I'm told that
- + ANSI specifies the shorter strings, and some programs
- + rely on these.
- +
- + *.h and some *.c:: ers/++jrb
- + merge mntlib and lib headers. a few .c files needed adjustments
- + because of this.
- +
- + obstack.c/obstack.h:: ++jrb
- + sanitize the ones from gcc 2.1 distribution for 16/32 ints and
- + add to lib.
- +
- + mincl:: ++jrb
- + add target for obstack.c
- +
- + bzero/bcmp/bcopy string.h:: ++jrb
- + get rid of the silly old lbXXX aliases.
- + add the MiNT _bxxx() aliases. should be useful with people like
- + the soz 1.33 author who dont distinguish between an int and the size
- + of an addressable object (under the guise of efficiency). big sigh!
- +
- + malloc.c:: ++jrb
- + split off realloc and calloc into their own files. put common
- + definitions in lib.h so that it may be included in realloc.c
- + and calloc.c.
- +
- + realloc.c/calloc.c:: ++jrb
- + new files.
- +
- + mincl:: ++jrb
- + add targets for realloc.o and calloc.o
- +
- + lib.h:: ++jrb
- + add common alloc defs
- + cleanup
- +
- + mincl: ++jrb
- + in all the rules, change any explicitly specified source filename
- + to $<, so that when VPATH is set the correct thing happens.
- +
- + ---------------------------- Patchlevel 80.5 ---------------------------
- + *:: ers/++jrb
- + start of merge of mnt/tos libs. all headers done. lots
- + of common files done. lots of minor adjustments all
- + over.
- +
- + console.c:: scott
- + We were doning a dev=LOOKUP(handle) in console_write_byte, than again
- + in flush_key_buff()
- +
- + eprintf.c:: ++jrb
- + turn say into a routine that calculates the strlen. there was already
- + a mistake there.
- +
- + ---------------------------- Patchlevel 81 ---------------------------
- *** 1.56 1992/04/13 15:50:45
- --- PatchLev.h 1992/06/03 14:46:15
- ***************
- *** 1,5 ****
-
- ! #define PatchLevel "80"
-
- /*
- *
- --- 1,5 ----
-
- ! #define PatchLevel "81"
-
- /*
- *
- *** 1.14 1992/02/04 17:11:06
- --- close.c 1992/06/03 14:46:17
- ***************
- *** 8,13 ****
- --- 8,14 ----
- #include <fcntl.h>
- #include <device.h>
- #include <stdlib.h>
- + #include <unistd.h>
-
- int (*pipeclose_p) __PROTO((int fd)) = 0;
-
- *** 1.12 1992/04/13 15:50:45
- --- console.c 1992/06/03 14:46:17
- ***************
- *** 165,177 ****
- int n;
- {
- char ch;
- - short dev;
-
- - dev = LOOKUP(handle);
- -
- if (__check_signals)
- ! flush_key_buff(dev);
- ! /* raw_out(dev, n); */
- ch = n;
- (void)Fwrite(handle, 1L, &ch);
- }
- --- 165,173 ----
- int n;
- {
- char ch;
-
- if (__check_signals)
- ! flush_key_buff(handle);
- ch = n;
- (void)Fwrite(handle, 1L, &ch);
- }
- ***************
- *** 199,210 ****
- ch = c & 0xff;
- if (ch == ('S'-'@')) { waiting = 1; }
- else if (ch == ('Q'-'@')) { waiting = 0; }
- ! else if (ch == __tchars[TC_INTRC])
- {
- p->head = p->tail;
- raise(SIGINT);
- }
- ! else if (ch == __tchars[TC_QUITC])
- {
- p->head = p->tail;
- raise(SIGQUIT);
- --- 195,206 ----
- ch = c & 0xff;
- if (ch == ('S'-'@')) { waiting = 1; }
- else if (ch == ('Q'-'@')) { waiting = 0; }
- ! else if (ch == (unsigned char)__tchars[TC_INTRC])
- {
- p->head = p->tail;
- raise(SIGINT);
- }
- ! else if (ch == (unsigned char)__tchars[TC_QUITC])
- {
- p->head = p->tail;
- raise(SIGQUIT);
- *** 1.19 1992/04/19 16:02:45
- --- mincl 1992/06/03 14:46:21
- ***************
- *** 18,40 ****
- bblink.o
- #
- # ANSI stuff + support
- ! ANSI = atol.o atof.o abort.o bsearch.o clock.o ctime.o ctype.o difftime.o \
- fopen.o fclose.o fdopen.o fflush.o fgetc.o fgets.o \
- fputc.o fputs.o fread.o fwrite.o fseek.o fsetpos.o \
- ! fprintf.o sprintf.o \
- fscanf.o scanf.o sscanf.o \
- getenv.o putenv.o gets.o getw.o localtim.o \
- ! malloc.o qsort.o raise.o rand.o setbuf.o setvbuf.o \
- setlocal.o strftime.o strtol.o system.o \
- tmpnam.o tmpfile.o \
- ltoa.o main.o doprnt.o div.o \
- ! strtoul.o fungetc.o filbuf.o getbuf.o
-
- #
- # other portable stuff
- PORT = alphasor.o abs.o catch.o dirent.o findfile.o ftw.o getpw.o \
- getlogin.o getopt.o getpass.o ident.o mktemp.o scandir.o strlwr.o \
- ! strrev.o regexp.o regsup.o textio.o random.o
-
- #
- # the string library
- --- 18,42 ----
- bblink.o
- #
- # ANSI stuff + support
- ! ANSI = atol.o atof.o abort.o bsearch.o \
- ! calloc.o clock.o ctime.o ctype.o difftime.o \
- fopen.o fclose.o fdopen.o fflush.o fgetc.o fgets.o \
- fputc.o fputs.o fread.o fwrite.o fseek.o fsetpos.o \
- ! fprintf.o eprintf.o sprintf.o \
- fscanf.o scanf.o sscanf.o \
- getenv.o putenv.o gets.o getw.o localtim.o \
- ! malloc.o qsort.o raise.o rand.o realloc.o \
- ! setbuf.o setvbuf.o \
- setlocal.o strftime.o strtol.o system.o \
- tmpnam.o tmpfile.o \
- ltoa.o main.o doprnt.o div.o \
- ! strtoul.o fungetc.o filbuf.o getbuf.o toxxx.o
-
- #
- # other portable stuff
- PORT = alphasor.o abs.o catch.o dirent.o findfile.o ftw.o getpw.o \
- getlogin.o getopt.o getpass.o ident.o mktemp.o scandir.o strlwr.o \
- ! strrev.o regexp.o regsup.o textio.o random.o obstack.o
-
- #
- # the string library
- ***************
- *** 74,84 ****
- #
- # osbind.o/gmon.o/fork.o CANNOT have -fomit-frame-pointer
- osbind.o: osbind.c
- ! $(CC) $(CFFLAGS) -c osbind.c
- gmon.o: gmon.c
- ! $(CC) $(CFFLAGS) -c gmon.c
- fork.o: fork.c
- ! $(CC) $(CFFLAGS) -c fork.c
-
- #
- # Assembler stuff that needs to be preprocessed by cpp into a .S
- --- 76,86 ----
- #
- # osbind.o/gmon.o/fork.o CANNOT have -fomit-frame-pointer
- osbind.o: osbind.c
- ! $(CC) $(CFFLAGS) -c $<
- gmon.o: gmon.c
- ! $(CC) $(CFFLAGS) -c $<
- fork.o: fork.c
- ! $(CC) $(CFFLAGS) -c $<
-
- #
- # Assembler stuff that needs to be preprocessed by cpp into a .S
- ***************
- *** 111,124 ****
- #
- # integer only io stuff
- idoprnt.o: doprnt.c
- ! $(CC) $(CFLAGS) -D__NO_FLOAT__ -c doprnt.c -o idoprnt.o
-
- iscanf.o: scanf.c
- ! $(CC) $(CFLAGS) -D__NO_FLOAT__ -c scanf.c -o iscanf.o
-
- # gcrt0
- gcrt0.o: crt0.c
- ! $(CC) $(CFLAGS) -D__GCRT0__ -c crt0.c -o gcrt0.o
-
- # other dependencies
- bcopy.o : bcopy.s
- --- 113,126 ----
- #
- # integer only io stuff
- idoprnt.o: doprnt.c
- ! $(CC) $(CFLAGS) -D__NO_FLOAT__ -c $< -o idoprnt.o
-
- iscanf.o: scanf.c
- ! $(CC) $(CFLAGS) -D__NO_FLOAT__ -c $< -o iscanf.o
-
- # gcrt0
- gcrt0.o: crt0.c
- ! $(CC) $(CFLAGS) -D__GCRT0__ -c $< -o gcrt0.o
-
- # other dependencies
- bcopy.o : bcopy.s
- *** 1.11 1992/04/13 15:50:45
- --- mkdir.c 1992/06/03 14:46:21
- ***************
- *** 15,21 ****
-
- int mkdir(_path, mode)
- const char *_path;
- ! int mode;
- {
- int rv, name_munged;
- char path[FILENAME_MAX];
- --- 15,21 ----
-
- int mkdir(_path, mode)
- const char *_path;
- ! unsigned int mode;
- {
- int rv, name_munged;
- char path[FILENAME_MAX];
- *** 1.18 1992/04/13 15:50:45
- --- stat.c 1992/06/03 14:46:24
- ***************
- *** 37,43 ****
- DIR *__opendir_chain = 0; /* chain of open directories from opendir */
-
- /* date for files (like root directories) that don't have one */
- ! #define OLDDATE unixtime(0,0)
-
- /*
- * check file cache for the file whose canonical (unx2dos) name is fullname.
- --- 37,43 ----
- DIR *__opendir_chain = 0; /* chain of open directories from opendir */
-
- /* date for files (like root directories) that don't have one */
- ! #define OLDDATE _unixtime(0,0)
-
- /*
- * check file cache for the file whose canonical (unx2dos) name is fullname.
- ***************
- *** 184,190 ****
- return -1;
- }
- st->st_mtime = st->st_ctime = st->st_atime =
- ! unixtime(d->d_time, d->d_date);
- st->st_ino = d->d_ino;
- st->st_attr = d->d_attribute;
- st->st_mode = 0644 | (d->d_attribute & FA_DIR ?
- --- 184,190 ----
- return -1;
- }
- st->st_mtime = st->st_ctime = st->st_atime =
- ! _unixtime(d->d_time, d->d_date);
- st->st_ino = d->d_ino;
- st->st_attr = d->d_attribute;
- st->st_mode = 0644 | (d->d_attribute & FA_DIR ?
- ***************
- *** 289,295 ****
- long oldplace;
-
- st->st_mtime = st->st_atime = st->st_ctime =
- ! unixtime(timestruct.time,timestruct.date);
- st->st_mode = S_IFREG | 0644; /* this may be false */
- st->st_attr = 0; /* because this is */
-
- --- 289,295 ----
- long oldplace;
-
- st->st_mtime = st->st_atime = st->st_ctime =
- ! _unixtime(timestruct.time,timestruct.date);
- st->st_mode = S_IFREG | 0644; /* this may be false */
- st->st_attr = 0; /* because this is */
-
- *** 1.22 1992/04/19 16:02:45
- --- unx2dos.c 1992/06/03 14:46:26
- ***************
- *** 6,11 ****
- --- 6,12 ----
- #include <types.h>
- #include <dirent.h>
- #include "symdir.h"
- + #include "lib.h"
- #ifndef _COMPILER_H
- #include <compiler.h>
- #endif
- ***************
- *** 607,613 ****
- */
-
- /* system default file name mapping function pointers */
- - typedef int (*fnmapfunc_t)(const char *, char *);
-
- static fnmapfunc_t ux2dos = _unx2dos;
- static fnmapfunc_t dos2ux = _dos2unx;
- --- 608,613 ----
- *** 1.1 1992/04/06 19:33:32
- --- _fltsi.cpp 1992/06/03 14:49:07
- ***************
- *** 12,20 ****
-
- __floatsidf:
- ___floatsidf:
- ! fmovel a7@(4),fp0 | load long int to fp0
- ! fintrzd a4@(4),fp0 | get double from fp0
- ! fmoved fp0,a7@-
- moveml a7@+,d0-d1
- rts
-
- --- 12,19 ----
-
- __floatsidf:
- ___floatsidf:
- ! fintrzd a7@(4),fp0 | load long int to fp0
- ! fmoved fp0,a7@- | get double from fp0
- moveml a7@+,d0-d1
- rts
-
- *** 1.4 1991/04/26 03:42:08
- --- abort.c 1992/06/03 14:49:09
- ***************
- *** 1,8 ****
- /* ERS */
-
- - #include <stddef.h>
- - #include <stdlib.h>
- #include <signal.h>
- #include <unistd.h>
-
- #ifndef SIGABRT
- --- 1,7 ----
- /* ERS */
-
- #include <signal.h>
- + #include <stdlib.h>
- #include <unistd.h>
-
- #ifndef SIGABRT
- ***************
- *** 10,20 ****
- #endif
-
- __EXITING abort()
- ! {
- ! #if 0 /* for now */
- raise(SIGABRT);
- ! #else
- ! raise(SIGIOT);
- ! #endif
- ! exit(-999);
- ! }
- --- 9,15 ----
- #endif
-
- __EXITING abort()
- ! {
- raise(SIGABRT);
- ! exit(127);
- ! }
- *** 1.7 1991/04/12 18:19:53
- --- access.c 1992/06/03 14:49:09
- ***************
- *** 4,10 ****
- --- 4,13 ----
- #include <stat.h>
- #include <fcntl.h>
- #include <errno.h>
- + #include <unistd.h>
-
- + extern int __mint;
- +
- int
- access(path, mode)
- const char *path;
- ***************
- *** 11,16 ****
- --- 14,20 ----
- int mode;
- {
- struct stat sb;
- + int uid, gid;
-
- if (stat(path, &sb) < 0)
- return -1; /* errno was set by stat() */
- ***************
- *** 20,27 ****
- /* somewhat crufty code -- relies on R_OK, etc. matching the bits in the
- file mode, but what the heck, we can do this
- */
- ! if ( ((sb.st_mode >> 6) & mode) == mode )
- ! return 0;
-
- errno = EACCESS; return -1;
- }
- --- 24,45 ----
- /* somewhat crufty code -- relies on R_OK, etc. matching the bits in the
- file mode, but what the heck, we can do this
- */
- ! if (__mint < 9 || ( (uid = geteuid()) == sb.st_uid ) ) {
- ! if ( ((sb.st_mode >> 6) & mode) == mode )
- ! return 0;
- ! else
- ! goto accdn;
- ! }
-
- + if ( (gid = getegid()) == sb.st_gid ) {
- + if ( ((sb.st_mode >> 3) & mode) == mode )
- + return 0;
- + else
- + goto accdn;
- + }
- +
- + if ( (sb.st_mode & mode) == mode)
- + return 0;
- + accdn:
- errno = EACCESS; return -1;
- }
- *** 1.5 1992/04/13 15:50:45
- --- alloca.s 1992/06/03 14:49:09
- ***************
- *** 19,24 ****
- subl d0,sp | increase stack frame size by that much
- movel sp,d0 | set up to return it
-
- ! subql #4,sp | new top of stack (real bug fix here)
-
- jmp a0@ | return by jmping via saved addr
- --- 19,24 ----
- subl d0,sp | increase stack frame size by that much
- movel sp,d0 | set up to return it
-
- ! lea sp@(-4),sp | new top of stack (real bug fix here)
-
- jmp a0@ | return by jmping via saved addr
- *** 1.10 1992/03/06 19:19:47
- --- bcmp.c 1992/06/03 14:49:10
- ***************
- *** 3,10 ****
- #include <assert.h>
-
- #undef ODD
- ! #define ODD(x) (((short)(x)) & 1) /* word ops are faster */
- ! #define INC(x, size) x = (const void *)(((const char *)(x)) + (size))
-
- /*
- * compare n bytes efficientlty
- --- 3,9 ----
- #include <assert.h>
-
- #undef ODD
- ! #define ODD(x) (((long)(x)) & 1)
-
- /*
- * compare n bytes efficientlty
- ***************
- *** 13,19 ****
- *
- * ++jrb bammi@dsrgsun.ces.cwru.edu
- */
- ! asm(".stabs \"_lbcmp\",5,0,0,_bcmp"); /* dept of clean tricks */
-
- int bcmp(src, dst, n)
- const void * src;
- --- 12,19 ----
- *
- * ++jrb bammi@dsrgsun.ces.cwru.edu
- */
- !
- ! #define INC(x, size) x = (const void *)(((const char *)(x)) + (size))
-
- int bcmp(src, dst, n)
- const void * src;
- ***************
- *** 20,25 ****
- --- 20,26 ----
- const void * dst;
- register size_t n;
- {
- +
- assert ((src != NULL) && (dst != NULL));
-
- if((src != dst) && (n > 0))
- *** 1.5 1992/04/13 15:50:45
- --- bcopy.s 1992/06/03 14:49:11
- ***************
- *** 3,14 ****
- | handles overlap, odd/even alignment
- | uses movem to copy 256 bytes blocks faster.
- | Alexander Lehmann alexlehm@iti.informatik.th-darmstadt.de
- ! | sortof inspired by jrb's bcopy
-
- .text
- .even
- .globl _bcopy
- ! .globl _lbcopy
- .globl _memcpy
- .globl _memmove
-
- --- 3,14 ----
- | handles overlap, odd/even alignment
- | uses movem to copy 256 bytes blocks faster.
- | Alexander Lehmann alexlehm@iti.informatik.th-darmstadt.de
- ! | sortof inspired by jrbs bcopy
-
- .text
- .even
- .globl _bcopy
- ! .globl __bcopy
- .globl _memcpy
- .globl _memmove
-
- ***************
- *** 29,35 ****
- | functions are aliased
-
- _bcopy:
- ! _lbcopy:
- movl sp@(4),a0 | src
- movl sp@(8),a1 | dest
- common: movl sp@(12),d0 | length
- --- 29,35 ----
- | functions are aliased
-
- _bcopy:
- ! __bcopy:
- movl sp@(4),a0 | src
- movl sp@(8),a1 | dest
- common: movl sp@(12),d0 | length
- ***************
- *** 49,55 ****
- jne slow_copy
- btst #0,d2 | both even ?
- jeq both_even
- ! movb a0@+,a1@+ | copy one byte, now we're both even
- subql #1,d0
- both_even:
- clrw d1 | save length less 256
- --- 49,55 ----
- jne slow_copy
- btst #0,d2 | both even ?
- jeq both_even
- ! movb a0@+,a1@+ | copy one byte, now we are both even
- subql #1,d0
- both_even:
- clrw d1 | save length less 256
- *** 1.7 1991/04/26 03:42:08
- --- bsearch.c 1992/06/03 14:49:11
- ***************
- *** 30,36 ****
- while(a <= b)
- {
- c = (a + b) >> 1; /* == ((a + b) / 2) */
- ! if (dir = (*cmp)((void *)((char *)base + c * size), key))
- {
- if (dir > 0)
- {
- --- 30,36 ----
- while(a <= b)
- {
- c = (a + b) >> 1; /* == ((a + b) / 2) */
- ! if (dir = (*cmp)((void *)((char *)base + (c * size)), key))
- {
- if (dir > 0)
- {
- *** 1.1 1992/04/06 19:33:32
- --- bzero.cpp 1992/06/03 14:49:11
- ***************
- *** 1,4 ****
- -
- | new version of bcopy and memset
- | uses movem to set 256 bytes blocks faster.
- | Alexander Lehmann alexlehm@iti.informatik.th-darmstadt.de
- --- 1,3 ----
- ***************
- *** 8,14 ****
- .text
- .even
- .globl _bzero
- ! .globl _lbzero
- .globl _memset
-
- | void *memset( void *dest, int val, size_t len );
- --- 7,13 ----
- .text
- .even
- .globl _bzero
- ! .globl __bzero
- .globl _memset
-
- | void *memset( void *dest, int val, size_t len );
- ***************
- *** 28,38 ****
- jra do_set
-
- | void bzero( void *dest, size_t length );
- ! | void lbzero( void *dest, size_t length );
- | return value not used (returns dest)
-
- _bzero:
- ! _lbzero:
- movl sp@(4),a0 | dest
- movl sp@(8),d1 | length
- jeq exit | length==0? (size_t)
- --- 27,37 ----
- jra do_set
-
- | void bzero( void *dest, size_t length );
- ! | void _bzero( void *dest, size_t length );
- | return value not used (returns dest)
-
- _bzero:
- ! __bzero:
- movl sp@(4),a0 | dest
- movl sp@(8),d1 | length
- jeq exit | length==0? (size_t)
- *** 1.9 1991/06/11 23:04:27
- --- chdir.c 1992/06/03 14:49:12
- ***************
- *** 1,9 ****
- - #include <stdio.h>
- #include <errno.h>
- #include <osbind.h>
- #include <stddef.h>
- #include <assert.h>
- #include <ctype.h>
- #include <unistd.h>
- #include "lib.h"
-
- --- 1,9 ----
- #include <errno.h>
- #include <osbind.h>
- #include <stddef.h>
- #include <assert.h>
- #include <ctype.h>
- + #include <limits.h>
- #include <unistd.h>
- #include "lib.h"
-
- ***************
- *** 17,23 ****
- {
- int drv, old;
- int r;
- ! char tmp[FILENAME_MAX];
- register char *d;
-
- assert ((dir != NULL));
- --- 17,23 ----
- {
- int drv, old;
- int r;
- ! char tmp[PATH_MAX];
- register char *d;
-
- assert ((dir != NULL));
- *** 1.5 1991/06/11 23:04:27
- --- chmod.c 1992/06/03 14:49:12
- ***************
- *** 5,16 ****
- #include <types.h>
- #include <stat.h>
- #include <osbind.h>
- ! #include <stdio.h>
- #include <errno.h>
- #include <unistd.h>
- - #include <support.h>
- #include "lib.h"
-
-
- int chmod(_path, mode)
- const char *_path;
- --- 5,17 ----
- #include <types.h>
- #include <stat.h>
- #include <osbind.h>
- ! #include <mintbind.h>
- ! #include <limits.h>
- #include <errno.h>
- #include <unistd.h>
- #include "lib.h"
-
- + extern int __mint;
-
- int chmod(_path, mode)
- const char *_path;
- ***************
- *** 17,31 ****
- int mode;
- {
- int dosattrib = 0, r;
- ! char path[FILENAME_MAX];
- struct stat stb;
-
- (void)unx2dos(_path, path);
-
- ! /* The following lines ensure that the archive bit isn't cleared */
- ! r = Fattrib(path, 0, dosattrib);
- ! if (r > 0 && (r & FA_CHANGED))
- ! dosattrib |= FA_CHANGED;
- #if 0
- if (!(mode & S_IREAD))
- dosattrib |= FA_HIDDEN;
- --- 18,42 ----
- int mode;
- {
- int dosattrib = 0, r;
- ! char path[PATH_MAX];
- struct stat stb;
-
- (void)unx2dos(_path, path);
-
- ! if (__mint >= 9) { /* use MiNT Fchmod function */
- ! r = Fchmod(path, mode);
- ! if (r) {
- ! errno = -r;
- ! return -1;
- ! }
- ! return 0;
- ! }
- !
- ! /* The following lines ensure that the archive bit isn't cleared */
- ! r = Fattrib(path, 0, dosattrib);
- ! if (r > 0 && (r & FA_CHANGED))
- ! dosattrib |= FA_CHANGED;
- !
- #if 0
- if (!(mode & S_IREAD))
- dosattrib |= FA_HIDDEN;
- ***************
- *** 45,55 ****
- return 0;
- }
-
- ! /* just fake these for now */
-
- ! int chown(name, uid, gid)
- ! const char *name;
- int uid, gid;
- {
- ! return 0;
- }
- --- 56,80 ----
- return 0;
- }
-
- ! /*
- ! * chown: this is faked if MiNT is not running
- ! */
-
- ! int chown(_name, uid, gid)
- ! const char *_name;
- int uid, gid;
- {
- ! int r;
- ! char name[PATH_MAX];
- !
- ! if (__mint >= 9) {
- ! (void)unx2dos(_name, name);
- ! r = Fchown(name, uid, gid);
- ! if (r) {
- ! errno = -r;
- ! return -1;
- ! }
- ! return 0;
- ! }
- ! return 0;
- }
- *** 1.7 1992/03/06 19:19:47
- --- ctype.c 1992/06/03 14:49:13
- ***************
- *** 65,79 ****
- };
-
- unsigned char *_ctype = &(_myctype[0]);
- -
- - int toupper(c)
- - int c;
- - {
- - return(islower(c) ? (c ^ 0x20) : (c));
- - }
- -
- - int tolower(c)
- - int c;
- - {
- - return(isupper(c) ? (c ^ 0x20) : (c));
- - }
- --- 65,67 ----
- *** 1.14 1992/04/19 16:02:45
- --- doprnt.c 1992/06/03 14:49:14
- ***************
- *** 52,60 ****
- --- 52,62 ----
- #include <math.h> /* mjr++ */
-
- #ifndef __GNUC__ /* gcc lib has these typedefs in sys/types.h */
- + #ifndef __MINT__ /* as does the MiNT library */
- typedef unsigned char u_char;
- typedef unsigned long u_long;
- #endif
- + #endif
-
- /* 11-bit exponent (VAX G floating point) is 308 decimal digits */
- #define MAXEXP 308
- ***************
- *** 314,320 ****
- if (_dd.i[0] == NAN_HI)
- {
- t = buf;
- ! t = strcpy(t, " Not A Number ");
- size = strlen(t);
- goto pforw;
- }
- --- 316,322 ----
- if (_dd.i[0] == NAN_HI)
- {
- t = buf;
- ! t = strcpy(t, "NaN");
- size = strlen(t);
- goto pforw;
- }
- ***************
- *** 345,353 ****
- {
- t = buf;
- if(softsign == 0)
- ! t = strcpy(t, " Infinity ");
- else
- ! t = strcpy(t, " -Infinity ");
- size = strlen(t);
- goto pforw;
- }
- --- 347,355 ----
- {
- t = buf;
- if(softsign == 0)
- ! t = strcpy(t, "+Inf");
- else
- ! t = strcpy(t, "-Inf");
- size = strlen(t);
- goto pforw;
- }
- ***************
- *** 400,406 ****
- * NUL in the first `prec' characters, and
- * strlen() will go further.
- */
- ! #ifdef __GNUC__
- char *p;
- void *memchr(const void *, int, size_t);
- #else
- --- 402,408 ----
- * NUL in the first `prec' characters, and
- * strlen() will go further.
- */
- ! #ifdef __STDC__
- char *p;
- void *memchr(const void *, int, size_t);
- #else
- ***************
- *** 538,544 ****
- register char *p, *t;
- register double fract;
- int dotrim, expcnt, gformat;
- ! double integer, tmp, modf(double, double *);
- char *exponent __PROTO((char *, int, int)),
- *round __PROTO((double, int *, char *, char *, int, char *));
-
- --- 540,546 ----
- register char *p, *t;
- register double fract;
- int dotrim, expcnt, gformat;
- ! double integer, tmp, modf __PROTO((double, double *));
- char *exponent __PROTO((char *, int, int)),
- *round __PROTO((double, int *, char *, char *, int, char *));
-
- *** 1.7 1991/04/26 03:42:08
- --- fclose.c 1992/06/03 14:49:15
- ***************
- *** 4,9 ****
- --- 4,11 ----
- #include <stdlib.h>
- #include <unistd.h>
-
- + extern int __mint;
- +
- int fclose(fp)
- register FILE *fp;
- {
- ***************
- *** 37,44 ****
- }
- #endif
- fp->_flag = 0; /* clear status */
- ! if(f & _IODEV) /* leave tty's alone */
- ! return(0);
- error |= close(fp->_file);
- return(error ? EOF : 0);
- }
- --- 39,47 ----
- }
- #endif
- fp->_flag = 0; /* clear status */
- ! if (__mint == 0)
- ! if(f & _IODEV) /* leave tty's alone */
- ! return(0);
- error |= close(fp->_file);
- return(error ? EOF : 0);
- }
- *** 1.10 1992/03/06 19:19:47
- --- fdopen.c 1992/06/03 14:49:15
- ***************
- *** 8,14 ****
- FILE *fdopen(h, mode)
- register int h;
- const register char *mode;
- ! {
- extern int __default_mode__; /* see binmode.c */
- register int i, iomode = 0, f = __default_mode__;
- register FILE *fp = NULL;
- --- 8,14 ----
- FILE *fdopen(h, mode)
- register int h;
- const register char *mode;
- ! {
- extern int __default_mode__; /* see binmode.c */
- register int i, iomode = 0, f = __default_mode__;
- register FILE *fp = NULL;
- ***************
- *** 17,31 ****
- for(i=0; (!fp && (i < _NFILE)); ++i)
- if(!(_iob[i]._flag & (_IORW | _IOREAD | _IOWRT)))
- fp = &_iob[i]; /* empty slot */
- ! if(!fp)
- ! {
- ! errno = EMFILE;
- ! return(NULL);
- ! }
- ! while(*mode)
- ! {
- ! switch(*mode++)
- ! {
- case 'r':
- f |= _IOREAD;
- break;
- --- 17,29 ----
- for(i=0; (!fp && (i < _NFILE)); ++i)
- if(!(_iob[i]._flag & (_IORW | _IOREAD | _IOWRT)))
- fp = &_iob[i]; /* empty slot */
- ! if(!fp) {
- ! errno = EMFILE;
- ! return(NULL);
- ! }
- !
- ! while(*mode) {
- ! switch(*mode++) {
- case 'r':
- f |= _IOREAD;
- break;
- ***************
- *** 47,56 ****
- case 't':
- f &= ~_IOBIN;
- break;
- ! default: /* Illegal file mode */
- return(NULL);
- }
- ! }
- if((i = (f & (_IORW | _IOREAD | _IOWRT))) == 0)
- return(NULL);
- else if(i == _IOREAD)
- --- 45,54 ----
- case 't':
- f &= ~_IOBIN;
- break;
- ! default: /* illegal file mode */
- return(NULL);
- }
- ! }
- if((i = (f & (_IORW | _IOREAD | _IOWRT))) == 0)
- return(NULL);
- else if(i == _IOREAD)
- ***************
- *** 59,64 ****
- --- 57,63 ----
- iomode |= O_WRONLY;
- else
- iomode |= O_RDWR;
- +
- if(isatty(h))
- f |= (_IODEV | _IONBF);
- else
- ***************
- *** 65,77 ****
- f |= _IOFBF;
- fp->_file = h; /* file handle */
- fp->_flag = f; /* file status flags */
- - #if 0
- - fp->_base = NULL; /* base of file buffer */
- - fp->_ptr = NULL; /* current buffer pointer */
- - fp->_bsiz = 0; /* buffer size */
- - fp->_cnt = 0; /* # of bytes in buffer */
- - #else
- _getbuf(fp);
- - #endif
- return(fp);
- ! }
- --- 64,69 ----
- f |= _IOFBF;
- fp->_file = h; /* file handle */
- fp->_flag = f; /* file status flags */
- _getbuf(fp);
- return(fp);
- ! }
- *** 1.4 1991/04/12 18:19:53
- --- fgets.c 1992/06/03 14:49:16
- ***************
- *** 13,19 ****
- register int c = EOF;
-
- assert((data != NULL));
- !
- while((--limit > 0) && ((c = getc(fp)) != EOF))
- if((*p++ = c) == '\n')
- break;
- --- 13,19 ----
- register int c = EOF;
-
- assert((data != NULL));
- !
- while((--limit > 0) && ((c = getc(fp)) != EOF))
- if((*p++ = c) == '\n')
- break;
- *** 1.9 1991/12/26 15:53:59
- --- findfile.c 1992/06/03 14:49:16
- ***************
- *** 9,22 ****
- Written by Eric R. Smith and placed in the public domain.
- */
-
- ! #include <stdio.h> /* needed only for FILENAME_MAX */
- #include <stddef.h>
- #include <types.h>
- #include <stat.h>
- #include <string.h>
- - #ifndef _COMPILER_H
- - #include <compiler.h>
- - #endif
-
- /* characters used to separate components in a path list */
- #define PATHSEP1 ':'
- --- 9,19 ----
- Written by Eric R. Smith and placed in the public domain.
- */
-
- ! #include <limits.h> /* needed for PATH_MAX */
- #include <stddef.h>
- #include <types.h>
- #include <stat.h>
- #include <string.h>
-
- /* characters used to separate components in a path list */
- #define PATHSEP1 ':'
- ***************
- *** 28,35 ****
-
- static char *nullext[] = { NULL };
-
- - static int EXISTS __PROTO((char *name));
- -
- static int
- EXISTS(name)
- char *name;
- --- 25,30 ----
- ***************
- *** 47,53 ****
- findfile(fname, fpath, fext)
- char *fname, *fpath, **fext;
- {
- ! static char try[FILENAME_MAX];
- char *s, *t, *extplace, **nextext, c;
- int hasext = 0, haspath = 0;
-
- --- 42,48 ----
- findfile(fname, fpath, fext)
- char *fname, *fpath, **fext;
- {
- ! static char try[PATH_MAX];
- char *s, *t, *extplace, **nextext, c;
- int hasext = 0, haspath = 0;
-
- *** 1.16 1992/01/29 20:58:29
- --- fopen.c 1992/06/03 14:49:16
- ***************
- *** 5,13 ****
- #include <fcntl.h>
- #include <unistd.h>
- #include <errno.h>
- - #ifndef _COMPILER_H
- - #include <compiler.h>
- - #endif
-
- __EXTERN void _getbuf __PROTO((FILE *));
-
- --- 5,10 ----
- ***************
- *** 16,23 ****
-
- extern int __default_mode__;
-
- - static FILE *_fopen __PROTO((const char *filename, const char *mode, FILE *fp));
- -
- static FILE *_fopen(filename, mode, fp)
- const char *filename;
- const register char *mode;
- --- 13,18 ----
- ***************
- *** 54,60 ****
- case 't':
- f &= ~_IOBIN;
- break;
- ! default: /* Illegal file mode */
- return(NULL);
- }
- }
- --- 49,55 ----
- case 't':
- f &= ~_IOBIN;
- break;
- ! default:
- return(NULL);
- }
- }
- ***************
- *** 85,91 ****
- const char *filename, *mode;
- {
- register int i;
- ! register FILE *fp = NULL;
-
- for(i=0; (!fp && (i < _NFILE)); ++i)
- if(!(_iob[i]._flag & (_IORW | _IOREAD | _IOWRT)))
- --- 80,86 ----
- const char *filename, *mode;
- {
- register int i;
- ! register FILE *fp = NULL;
-
- for(i=0; (!fp && (i < _NFILE)); ++i)
- if(!(_iob[i]._flag & (_IORW | _IOREAD | _IOWRT)))
- ***************
- *** 99,111 ****
- }
- else
- {
- ! errno = EMFILE;
- ! return NULL;
- }
- }
-
- /*
- ! * re-coded, foobared code ifdef'ed below
- *
- * ++jrb
- */
- --- 94,106 ----
- }
- else
- {
- ! errno = EMFILE;
- ! return NULL;
- }
- }
-
- /*
- ! * re-coded, foobared code deleted
- *
- * ++jrb
- */
- ***************
- *** 124,131 ****
- if(fflush(fp) != 0) return NULL; /* flush err */
- if(close(fp->_file) != 0) return NULL; /* close err */
- #else
- ! /* ANSI says ignore errors */
- ! (void)fflush(fp); (void)close(fp->_file);
- #endif
- }
- /* save buffer discipline and setbuf settings, and _IOWRT just for
- --- 119,125 ----
- if(fflush(fp) != 0) return NULL; /* flush err */
- if(close(fp->_file) != 0) return NULL; /* close err */
- #else
- ! fflush(fp); close(fp->_file); /* ANSI says ignore errors */
- #endif
- }
- /* save buffer discipline and setbuf settings, and _IOWRT just for
- *** 1.14 1991/06/20 02:12:19
- --- fprintf.c 1992/06/03 14:49:17
- ***************
- *** 1,58 ****
- - /* from Dale Schumacher's dLibs */
- -
- #include <stdio.h>
- #include <stdarg.h>
- - #include <compiler.h>
- #include "lib.h"
-
- ! __EXTERN int _doprnt __PROTO((FILE *file, const char *fmt, va_list argp));
-
- ! #ifdef __STDC__
- int fprintf(FILE *fp, const char *fmt, ...)
- #else
- ! int fprintf(fp, fmt)
- ! FILE *fp;
- ! const char *fmt;
- #endif
- ! {
- ! va_list argp;
- ! va_start(argp, fmt);
- ! return(_doprnt(fp, fmt, argp));
- ! }
-
- ! int vfprintf(fp, fmt, args)
- FILE *fp;
- const char *fmt;
- va_list args;
- ! {
- return(_doprnt(fp, fmt, args));
- ! }
-
- ! #ifdef __STDC__
- int printf(const char *fmt, ...)
- #else
- ! int printf(fmt)
- ! const char *fmt;
- #endif
- ! {
- ! va_list argp;
- ! va_start(argp, fmt);
- ! return(_doprnt(stdout, fmt, argp));
- ! }
-
- ! int vprintf(fmt, args)
- const char *fmt;
- va_list args;
- - {
- - return(_doprnt(stdout, fmt, args));
- - }
- -
- - /* This is used by the `assert' macro. */
- - void __eprintf (string, expression, line, filename)
- - const char *string;
- - const char *expression;
- - const long line;
- - const char *filename; /* note if STDC then filename is already in string */
- {
- ! (void)fprintf(stderr, string, expression, line, filename);
- }
- --- 1,53 ----
- #include <stdio.h>
- #include <stdarg.h>
- #include "lib.h"
-
- ! /* revised 4/15/92 sb -- moved __eprintf to a separate file to avoid conflict
- ! with libm.a's printf */
-
- ! #if __STDC__
- int fprintf(FILE *fp, const char *fmt, ...)
- #else
- ! int fprintf(fp, fmt) FILE *fp; const char *fmt;
- #endif
- ! {
- ! int r;
- ! va_list args;
- !
- ! va_start(args, fmt);
- ! r = _doprnt(fp, fmt, args);
- ! va_end(args);
- ! return r;
- ! }
-
- ! int
- ! vfprintf(fp, fmt, args)
- FILE *fp;
- const char *fmt;
- va_list args;
- ! {
- return(_doprnt(fp, fmt, args));
- ! }
-
- ! #if __STDC__
- int printf(const char *fmt, ...)
- #else
- ! int printf(fmt) const char *fmt;
- #endif
- ! {
- ! va_list args;
- ! int r;
- !
- ! va_start(args, fmt);
- ! r = _doprnt(stdout, fmt, args);
- ! va_end(args);
- ! return r;
- ! }
-
- ! int
- ! vprintf(fmt, args)
- const char *fmt;
- va_list args;
- {
- ! return(_doprnt(stdout, fmt, args));
- }
- *** 1.11 1992/01/29 20:58:29
- --- fputc.c 1992/06/03 14:49:17
- ***************
- *** 1,7 ****
- /* from Dale Schumacher's dLibs */
-
- #include <stdio.h>
- - #include <unistd.h>
- #include "lib.h"
-
- #ifndef TRUE
- --- 1,6 ----
- ***************
- *** 12,18 ****
- int fputc(c, fp)
- register int c;
- register FILE *fp;
- ! {
- register int nl = FALSE;
- register long m;
- unsigned int f = fp->_flag;
- --- 11,17 ----
- int fputc(c, fp)
- register int c;
- register FILE *fp;
- ! {
- register int nl = FALSE;
- register long m;
- unsigned int f = fp->_flag;
- ***************
- *** 23,54 ****
- f = (fp->_flag &= ~(_IOREAD | _IOEOF));
- }
- if(!(f & _IOWRT) /* not opened for write? */
- ! || (f & (_IOERR | _IOEOF))) /* error/eof conditions? */
- return(EOF);
-
- if(!(f & _IOBIN) && (c == '\n')) /* NL -> CR+LF ? */
- ! {
- c = '\r';
- nl = TRUE;
- ! }
- _fputc:
- *(fp->_ptr)++ = c; fp->_cnt++;
- if( (fp->_cnt >= fp->_bsiz) ||
- ((f & _IOLBF) && (c == '\n')) ) /* flush line buffd stream on \n */
- ! {
- m = fp->_cnt;
- fp->_cnt = 0;
- fp->_ptr = fp->_base;
- ! if(_write(fp->_file, fp->_base, m) != m)
- ! {
- fp->_flag |= _IOERR;
- return(EOF);
- - }
- }
- ! if(nl && (c == '\r')) /* NL -> CR+LF ? */
- ! {
- c = '\n';
- goto _fputc;
- - }
- - return(c & 0xff);
- }
- --- 22,51 ----
- f = (fp->_flag &= ~(_IOREAD | _IOEOF));
- }
- if(!(f & _IOWRT) /* not opened for write? */
- ! || (f & (_IOERR | _IOEOF))) /* error/eof conditions? */
- return(EOF);
-
- if(!(f & _IOBIN) && (c == '\n')) /* NL -> CR+LF ? */
- ! {
- c = '\r';
- nl = TRUE;
- ! }
- _fputc:
- *(fp->_ptr)++ = c; fp->_cnt++;
- if( (fp->_cnt >= fp->_bsiz) ||
- ((f & _IOLBF) && (c == '\n')) ) /* flush line buffd stream on \n */
- ! {
- m = fp->_cnt;
- fp->_cnt = 0;
- fp->_ptr = fp->_base;
- ! if(_write(fp->_file, fp->_base, m) != m) {
- fp->_flag |= _IOERR;
- return(EOF);
- }
- ! }
- ! if(nl && (c == '\r')) { /* NL -> CR+LF ? */
- c = '\n';
- goto _fputc;
- }
- + return(c & 0xff);
- + }
- *** 1.6 1992/03/06 19:19:47
- --- ftw.c 1992/06/03 14:49:18
- ***************
- *** 18,28 ****
- int
- ftw(directory, funcptr, depth)
- char *directory;
- - #if __STDC__
- - int (*funcptr)(char *name, struct stat *statp, int flag);
- - #else
- int (*funcptr)();
- - #endif
- int depth;
- {
- register DIR *dirp;
- --- 18,24 ----
- ***************
- *** 30,39 ****
- --- 26,39 ----
- struct stat stats;
- register char *p;
- register int i;
- + #ifndef __MINT__
- long seekpoint;
- + #endif
- char *fullpath;
-
- + #ifndef __MINT__
- seekpoint = 0; /* avoid spurious warning from gcc -Wall */
- + #endif
-
- /* If can't stat, tell the user so. */
- if (stat(directory, &stats) < 0)
- ***************
- *** 58,64 ****
-
- /* Get ready to hold the full paths. */
- i = strlen(directory);
- ! fullpath = malloc((size_t)(i + 1 + MAXNAMLEN + 1));
- if (fullpath == NULL) {
- closedir(dirp);
- return -1;
- --- 58,64 ----
-
- /* Get ready to hold the full paths. */
- i = strlen(directory);
- ! fullpath = (char *) malloc( (size_t) (i + 1 + MAXNAMLEN + 1) );
- if (fullpath == NULL) {
- closedir(dirp);
- return -1;
- ***************
- *** 71,76 ****
- --- 71,77 ----
- /* Read all entries in the directory.. */
- while (entp = readdir(dirp))
- if (!EQ(entp->d_name, ".") && !EQ(entp->d_name, "..")) {
- + #ifndef __MINT__
- if (depth <= 1) {
- /* Going too deep; checkpoint and close this directory. */
- seekpoint = telldir(dirp);
- ***************
- *** 77,83 ****
- closedir(dirp);
- dirp = NULL;
- }
- !
- /* Process the file. */
- (void)strcpy(p, entp->d_name);
- i = ftw(fullpath, funcptr, depth - 1);
- --- 78,84 ----
- closedir(dirp);
- dirp = NULL;
- }
- ! #endif
- /* Process the file. */
- (void)strcpy(p, entp->d_name);
- i = ftw(fullpath, funcptr, depth - 1);
- ***************
- *** 89,94 ****
- --- 90,96 ----
- return i;
- }
-
- + #ifndef __MINT__
- /* Reopen the directory if necessary. */
- if (dirp == NULL) {
- dirp = opendir(directory);
- ***************
- *** 98,103 ****
- --- 100,106 ----
- }
- seekdir(dirp, seekpoint);
- }
- + #endif
- }
-
- /* Clean up. */
- *** 1.6 1992/03/22 21:57:30
- --- getlogin.c 1992/06/03 14:49:19
- ***************
- *** 3,13 ****
- */
-
- #include <pwd.h>
- - #include <support.h>
- - #include <unistd.h>
- #include <string.h>
- #include <stdlib.h>
- #include <memory.h>
-
- static char *logname = NULL;
-
- --- 3,16 ----
- */
-
- #include <pwd.h>
- #include <string.h>
- #include <stdlib.h>
- #include <memory.h>
- + #include <unistd.h>
- +
- + #ifdef __GNUC__
- + #define alloca __builtin_alloca
- + #endif
-
- static char *logname = NULL;
-
- *** 1.8 1992/04/19 16:02:45
- --- getopt.c 1992/06/03 14:49:19
- ***************
- *** 14,27 ****
- #include <stddef.h>
- #include <stdio.h>
- #include <string.h>
- - #include <unistd.h>
-
- int opterr = 1; /* error => print message */
- int optind = 1; /* next argv[] index */
- char *optarg = NULL; /* option parameter if any */
-
- - static char mtail[] = " -- x\n";
- -
- static int
- Err( name, mess, c ) /* returns '?' */
- char *name; /* program name argv[0] */
- --- 14,24 ----
- ***************
- *** 29,41 ****
- int c; /* defective option letter */
- {
- if ( opterr )
- ! {
- ! mtail[4] = (char)c;
- ! (void) fputs(name, stderr);
- ! (void) fputs(": ", stderr);
- ! (void) fputs(mess, stderr);
- ! (void) fputs(&mtail[0], stderr);
- ! }
- return '?'; /* erroneous-option marker */
- }
-
- --- 26,36 ----
- int c; /* defective option letter */
- {
- if ( opterr )
- ! (void) fprintf( stderr,
- ! "%s: %s -- %c\n",
- ! name, mess, c
- ! );
- !
- return '?'; /* erroneous-option marker */
- }
-
- ***************
- *** 42,48 ****
- int
- getopt( argc, argv, optstring ) /* returns letter, '?', EOF */
- int argc; /* argument count from main */
- ! char *const *argv; /* argument vector from main */
- const char *optstring; /* allowed args, e.g. "ab:c" */
- {
- static int sp = 1; /* position within argument */
- --- 37,43 ----
- int
- getopt( argc, argv, optstring ) /* returns letter, '?', EOF */
- int argc; /* argument count from main */
- ! const char *argv[]; /* argument vector from main */
- const char *optstring; /* allowed args, e.g. "ab:c" */
- {
- static int sp = 1; /* position within argument */
- *** 1.4 1991/04/12 18:19:53
- --- getpid.c 1992/06/03 14:49:19
- ***************
- *** 1,19 ****
- ! /* from Dale Schumacher's dLibs library */
- #include <unistd.h>
- #include <basepage.h>
-
- ! int getpid()
- ! {
- ! register unsigned long n;
-
- ! n = (unsigned long) _base; /* load process base address */
- ! return(0x7FFF & (n >> 8)); /* create unique pid from it */
- ! }
- !
- ! int getppid()
- ! {
- ! register unsigned long n;
- !
- ! n = (unsigned long) _base->p_parent; /* load parents base address */
- ! return(0x7FFF & (n >> 8)); /* create unique pid from it */
- ! }
- --- 1,9 ----
- ! #include <osbind.h>
- #include <unistd.h>
- #include <basepage.h>
- + #include "mintbind.h"
-
- ! extern int __mint;
-
- ! int getpid() { return __mint ? Pgetpid() : ( ((long)_base) >> 8 ); }
- ! int getppid() { return __mint ? Pgetppid() : (((long)(_base->p_parent)) >> 8); }
- *** 1.9 1992/01/29 20:58:29
- --- getpw.c 1992/06/03 14:49:20
- ***************
- *** 29,41 ****
- arnold@emoryu1.{CSNET, UUCP, ARPA, BITNET}
- */
-
- #include <stdio.h>
- - #include <types.h>
- #include <pwd.h>
- #include <unistd.h>
- - #include <support.h>
- - #include <stdlib.h>
- #include <string.h>
-
- static char *pwdfile = "/etc/passwd"; /* default passwd file */
-
- --- 29,41 ----
- arnold@emoryu1.{CSNET, UUCP, ARPA, BITNET}
- */
-
- + /* minorly customized by ERS for the MiNT library */
- +
- #include <stdio.h>
- #include <pwd.h>
- #include <unistd.h>
- #include <string.h>
- + #include <stdlib.h>
-
- static char *pwdfile = "/etc/passwd"; /* default passwd file */
-
- ***************
- *** 42,48 ****
- static FILE *fp = NULL;
- static struct passwd curentry; /* static data to return */
-
- ! static int nextent(void);
-
- void setpwfile (cp)
- char *cp;
- --- 42,48 ----
- static FILE *fp = NULL;
- static struct passwd curentry; /* static data to return */
-
- ! static int nextent __PROTO((void));
-
- void setpwfile (cp)
- char *cp;
- ***************
- *** 51,57 ****
- if(cp) pwdfile = cp;
- }
-
- ! int setpwent ()
- {
- if (fp)
- rewind (fp);
- --- 51,57 ----
- if(cp) pwdfile = cp;
- }
-
- ! void setpwent ()
- {
- if (fp)
- rewind (fp);
- ***************
- *** 65,76 ****
- fprintf (stderr,
- "setpwent: %s non-existant or unreadable.\n", pwdfile);
- #endif
- - return (0);
- }
- - return (1);
- }
-
- ! int endpwent ()
- {
- if (fp)
- {
- --- 65,74 ----
- fprintf (stderr,
- "setpwent: %s non-existant or unreadable.\n", pwdfile);
- #endif
- }
- }
-
- ! void endpwent ()
- {
- if (fp)
- {
- ***************
- *** 77,89 ****
- fclose (fp);
- fp = NULL;
- }
- - return 1;
- }
-
- struct passwd *getpwent ()
- {
- ! if (! fp && ! setpwent ())
- ! return (NULL);
-
- if (! nextent ())
- return (NULL);
- --- 75,89 ----
- fclose (fp);
- fp = NULL;
- }
- }
-
- struct passwd *getpwent ()
- {
- ! if (! fp ) {
- ! setpwent();
- ! if (! fp )
- ! return (NULL);
- ! }
-
- if (! nextent ())
- return (NULL);
- ***************
- *** 91,106 ****
- return (& curentry);
- }
-
- - #if __STDC__
- - struct passwd *getpwuid (uid_t uid)
- - #else
- struct passwd *getpwuid (uid)
- ! uid_t uid;
- ! #endif
- {
- ! if (! setpwent ())
- ! return (NULL);
- !
- while (nextent ())
- if (curentry.pw_uid == uid)
- return (& curentry);
- --- 91,100 ----
- return (& curentry);
- }
-
- struct passwd *getpwuid (uid)
- ! register int uid;
- {
- ! setpwent ();
- while (nextent ())
- if (curentry.pw_uid == uid)
- return (& curentry);
- ***************
- *** 111,118 ****
- struct passwd *getpwnam (name)
- register const char *name;
- {
- ! if (! setpwent ())
- ! return (NULL);
-
- while (nextent ())
- if (strcmp (curentry.pw_name, name) == 0)
- --- 105,111 ----
- struct passwd *getpwnam (name)
- register const char *name;
- {
- ! setpwent ();
-
- while (nextent ())
- if (strcmp (curentry.pw_name, name) == 0)
- ***************
- *** 121,134 ****
- return (NULL);
- }
-
- static char savbuf[BUFSIZ];
-
- static int nextent ()
- {
- register char *cp;
-
- ! if (! fp && ! setpwent ())
- ! return (0);
-
- while (fgets (savbuf, sizeof(savbuf), fp) != NULL)
- {
- --- 114,134 ----
- return (NULL);
- }
-
- + #ifdef atarist
- + static char savbuf[256]; /* BUFSIZ seems bigger than necessary! */
- + #else
- static char savbuf[BUFSIZ];
- + #endif
-
- static int nextent ()
- {
- register char *cp;
-
- ! if (! fp ) {
- ! setpwent ();
- ! if (! fp )
- ! return (0);
- ! }
-
- while (fgets (savbuf, sizeof(savbuf), fp) != NULL)
- {
- *** 1.6 1992/04/13 15:50:45
- --- getuid.c 1992/06/03 14:49:20
- ***************
- *** 1,26 ****
- ! /* fake UNIX getuid, setuid, etc. calls.
- ! In fact, all we can do is pretend.
- ! By ERS
- ! */
- !
- #include <unistd.h>
- !
- ! /* pretending we are root (0,0) is probably not a good idea */
- ! static uid_t euid = 1, uid = 1;
- ! static gid_t egid = 1, gid = 1;
- !
- ! uid_t getuid() { return uid; }
- ! uid_t geteuid(){ return euid; }
- !
- ! gid_t getgid() { return gid; }
- ! gid_t getegid() { return egid; }
- !
- ! uid_t setuid(x) int x; { return uid = x; }
- ! gid_t setgid(x) int x; { return gid = x; }
- !
- ! uid_t seteuid(x) int x; { return euid = x; }
- ! gid_t setegid(x) int x; { return egid = x; }
- !
- ! int setpgrp() { return getpid(); }
- ! int getpgrp() { return getpid(); }
-
- --- 1,73 ----
- ! #include <sys/types.h>
- #include <unistd.h>
- ! #include <osbind.h>
- ! #include <mintbind.h>
- ! #include <errno.h>
- !
- ! extern int __mint;
- !
- ! static int __uid = 1, __gid = 1;
- !
- ! uid_t getuid() { return __mint ? Pgetuid() : __uid; }
- ! gid_t getgid() { return __mint ? Pgetgid() : __gid; }
- !
- ! uid_t geteuid() { return getuid(); }
- ! gid_t getegid() { return getgid(); }
- !
- ! int setuid(x)
- ! int x;
- ! {
- ! long r;
- !
- ! if (__mint) {
- ! r = Psetuid(x);
- ! if (r) {
- ! errno = -r;
- ! return -1;
- ! }
- ! return 0;
- ! }
- ! __uid = x;
- ! return 0;
- ! }
- !
- ! int setgid(x)
- ! int x;
- ! {
- ! long r;
- !
- ! if (__mint) {
- ! r = Psetgid(x);
- ! if (r) {
- ! errno = -r;
- ! return -1;
- ! }
- ! return 0;
- ! }
- ! __gid = x;
- ! return 0;
- ! }
- !
- ! int setreuid(ruid,euid)
- ! int ruid, euid;
- ! {
- ! return setuid(euid);
- ! }
- !
- ! int setregid(rgid,egid)
- ! int rgid, egid;
- ! {
- ! return setgid(egid);
- ! }
- !
- ! /* note: BSD getpgrp takes an argument, but ours doesn't */
- ! int getpgrp() { return __mint ? Pgetpgrp() : 0; }
- !
- ! int setpgrp(pid, grp)
- ! int pid, grp;
- ! {
- ! return __mint ? Psetpgrp(pid, grp) : 0;
- ! }
-
- + int seteuid(x) int x; { return setuid(x); }
- + int setegid(x) int x; { return setgid(x); }
- *** 1.8 1992/04/06 19:33:32
- --- gmon.c 1992/06/03 14:49:20
- ***************
- *** 16,21 ****
- --- 16,22 ----
- #include <basepage.h>
- #include <sysvars.h>
- #include <xbra.h>
- + #include <string.h>
- #ifndef _COMPILER_H
- #include <compiler.h>
- #endif
- ***************
- *** 617,623 ****
- ((unsigned long)Setexc(exc, -1L) - offsetof(xbra_struct, jump));
- if(this == me)
- { /* at the head, just unlink */
- ! Setexc(exc, me->next);
- return;
- }
- /* otherwise find me in the chain and unlink */
- --- 618,624 ----
- ((unsigned long)Setexc(exc, -1L) - offsetof(xbra_struct, jump));
- if(this == me)
- { /* at the head, just unlink */
- ! (void)Setexc(exc, me->next);
- return;
- }
- /* otherwise find me in the chain and unlink */
- ***************
- *** 630,636 ****
- if(this->xbra_magic != _XBRA_MAGIC)
- { /* shame on you */
- Super(save_ssp);
- ! Setexc(exc, me->next); /* nuke it, otherwise it may call ME */
- return; /* after i am deinstalled */
- }
- }
- --- 631,637 ----
- if(this->xbra_magic != _XBRA_MAGIC)
- { /* shame on you */
- Super(save_ssp);
- ! (void)Setexc(exc, me->next); /* nuke it, otherwise it may call ME */
- return; /* after i am deinstalled */
- }
- }
- *** 1.4 1991/04/26 03:42:08
- --- grp.c 1992/06/03 14:49:21
- ***************
- *** 1,47 ****
- /*
- ! * faking of group id's. written by ERS; it's public domain, if
- ! * you want it!
- */
-
- #include <string.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <grp.h>
-
- ! __EXTERN char * getlogin __PROTO((void));
-
- ! static char root_str[] = "root";
- ! static char user_str[80];
-
- ! static char *root_mem[] = { root_str, (char *)0 };
- ! static char *user_mem[] = { root_str, user_str, (char *)0 };
-
- ! static struct group root_group = { root_str, "", 0, root_mem };
- ! static struct group user_group = { "user", "", 1, user_mem };
-
- ! struct group *
- ! getgrgid(gid)
- ! int gid;
- {
- ! if (gid == 0)
- ! return &root_group;
- ! else if (gid == 1) {
- ! strcpy(user_str, getlogin());
- ! return &user_group;
- }
- - else
- - return 0;
- }
-
- ! struct group *
- ! getgrnam(name)
- ! char *name;
- ! {
- ! strcpy(user_str, getlogin());
- ! if (!strcmp(name, root_str))
- ! return &root_group;
- ! else if (!strcmp(name, "user"))
- ! return &user_group;
- else
- ! return 0;
- }
- --- 1,174 ----
- /*
- ! * Routines for reading information from /etc/group.
- ! * Written by Eric Smith, based on Arnold Robbins' public domain
- ! * getpwent routines (see getpw.c).
- */
-
- + #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <grp.h>
-
- ! static char *grpfile = "/etc/group"; /* default group file */
- ! static FILE *fp;
-
- ! static struct group curentry; /* static data to return */
-
- ! static int nextent __PROTO((void));
-
- ! void setgrent ()
- ! {
- ! if (fp)
- ! rewind (fp);
- ! #ifdef atarist
- ! else if ((fp = fopen (grpfile, "rt")) == NULL)
- ! #else
- ! else if ((fp = fopen (grpfile, "r")) == NULL)
- ! #endif
- ! {
- ! #ifdef VERBOSE
- ! fprintf (stderr,
- ! "setgrent: %s non-existant or unreadable.\n", grpfile);
- ! #endif
- ! }
- ! }
-
- ! void endgrent ()
- {
- ! if (fp)
- ! {
- ! fclose (fp);
- ! fp = NULL;
- }
- }
-
- ! struct group *getgrent ()
- ! {
- ! if (!fp) setgrent();
- ! if (!fp) return NULL;
- !
- ! if (! nextent ())
- ! return (NULL);
- else
- ! return (& curentry);
- ! }
- !
- ! struct group *getgrgid (gid)
- ! int gid;
- ! {
- ! setgrent();
- !
- ! while (nextent ())
- ! if (curentry.gr_gid == gid)
- ! return (& curentry);
- !
- ! return (NULL);
- ! }
- !
- ! struct group *getgrnam (name)
- ! register char *name;
- ! {
- ! setgrent();
- !
- ! while (nextent ())
- ! if (strcmp (curentry.gr_name, name) == 0)
- ! return (& curentry);
- !
- ! return (NULL);
- ! }
- !
- ! #define MAX_MEMBERS 128 /* max. number of members in a group */
- !
- ! static char savbuf[512];
- ! static char *memb[MAX_MEMBERS];
- !
- ! static int nextent ()
- ! {
- ! register char *cp;
- ! register int i;
- !
- ! if (!fp) setgrent();
- ! if (!fp) return 0;
- !
- ! if (fgets (savbuf, sizeof(savbuf), fp) != NULL)
- ! {
- ! for (cp = savbuf; *cp && *cp != ':'; cp++)
- ! ;
- ! curentry.gr_name = savbuf;
- ! *cp++ = '\0';
- ! curentry.gr_passwd = cp;
- ! for (; *cp && *cp != ':'; cp++)
- ! ;
- ! *cp++ = '\0';
- ! curentry.gr_gid = atoi (cp);
- ! for (; *cp && *cp != ':'; cp++)
- ! ;
- !
- ! *cp++ = '\0';
- !
- ! i = 0;
- ! while( *cp ) {
- ! if (i >= MAX_MEMBERS-1) break;
- ! memb[i++] = cp;
- ! for(; *cp && *cp != ',' && *cp != '\n'; cp++)
- ! ;
- ! if (*cp == '\n')
- ! *cp = 0;
- ! else if (*cp)
- ! *cp++ = 0;
- ! }
- ! memb[i] = NULL;
- ! curentry.gr_mem = memb;
- ! return (1);
- ! }
- ! return (0);
- ! }
- !
- ! #ifdef TEST
- ! int
- ! main (argc, argv)
- ! int argc;
- ! char **argv;
- ! {
- ! struct group *gr;
- ! char **m;
- !
- ! if (argc > 1) {
- ! grpfile = argv[1];
- ! }
- !
- ! setgrent ();
- ! while ((gr = getgrent ()) != NULL)
- ! {
- ! printf ("%s:[%s] %d\n",
- ! gr->gr_name,
- ! gr->gr_passwd,
- ! gr->gr_gid);
- ! for (m = gr->gr_mem; *m; m++) {
- ! printf("\t%s\n", *m);
- ! }
- ! }
- ! endgrent ();
- !
- ! if (gr = getgrnam ("mail")) {
- ! printf ("%s:[%s] %d\n",
- ! gr->gr_name,
- ! gr->gr_passwd,
- ! gr->gr_gid);
- ! for (m = gr->gr_mem; *m; m++) {
- ! printf("\t%s\n", *m);
- ! }
- ! }
- ! if (gr = getgrgid (1)) {
- ! printf ("%s:[%s] %d\n",
- ! gr->gr_name,
- ! gr->gr_passwd,
- ! gr->gr_gid);
- ! for (m = gr->gr_mem; *m; m++) {
- ! printf("\t%s\n", *m);
- ! }
- ! }
- ! return 0;
- }
- + #endif
- *** 1.5 1991/12/26 15:53:59
- --- lib.h 1992/06/03 14:49:22
- ***************
- *** 8,13 ****
- --- 8,14 ----
- #include <compiler.h>
- #endif
-
- + #include <stdio.h> /* for FILE */
- #include <time.h> /* for time_t */
-
- /* filename mapping function type */
- ***************
- *** 14,46 ****
- #ifndef __FNMAP
- #define __FNMAP
- #ifdef __STDC__
- ! typedef void (*fnmapfunc_t)(const char *, char *);
- #else
- ! typedef void (*fnmapfunc_t)();
- #endif
- #endif
-
- ! int _unx2dos __PROTO((const char *, char *));
- ! int _dos2unx __PROTO((const char *, char *));
- ! int unx2dos __PROTO((const char *, char *));
- ! int dos2unx __PROTO((const char *, char *));
- ! int spawnve __PROTO((int, char *, char **, char **));
- ! int console_input_status __PROTO((int));
- ! unsigned int console_read_byte __PROTO((int));
- ! void console_write_byte __PROTO((int, int));
- ! int dos2unx __PROTO((const char *, char *));
- ! time_t dostime __PROTO((time_t));
- ! char * findfile __PROTO((char *, char *, char **));
- ! char * _itoa __PROTO((int, char *, int));
- ! char * _ltoa __PROTO((long, char *, int));
- ! char * _ultoa __PROTO((unsigned long, char *, int));
- ! time_t unixtime __PROTO((unsigned int, unsigned int));
- ! int unx2dos __PROTO((const char *, char *));
- ! void fnmapfunc __PROTO((fnmapfunc_t u2dos, fnmapfunc_t dos2u));
- ! long get_sysvar __PROTO((void *var));
- ! void set_sysvar_to_long __PROTO((void *var, long val));
-
- ! __EXTERN __EXITING __exit __PROTO((long status));
- ! __EXTERN char *_itoa __PROTO((int, char *, int));
-
- #endif /* _LIB_H */
- --- 15,71 ----
- #ifndef __FNMAP
- #define __FNMAP
- #ifdef __STDC__
- ! typedef int (*fnmapfunc_t)(const char *, char *);
- #else
- ! typedef int (*fnmapfunc_t)();
- #endif
- #endif
-
- ! __EXTERN int _unx2dos __PROTO((const char *, char *));
- ! __EXTERN int _dos2unx __PROTO((const char *, char *));
- ! __EXTERN int unx2dos __PROTO((const char *, char *));
- ! __EXTERN int dos2unx __PROTO((const char *, char *));
- ! __EXTERN void fnmapfunc __PROTO((fnmapfunc_t u2dos, fnmapfunc_t dos2u));
-
- ! __EXTERN int spawnve __PROTO((int, char *, char **, char **));
- !
- ! __EXTERN long _write __PROTO((int, const void *, unsigned long));
- ! __EXTERN long _read __PROTO((int, void *, unsigned long));
- ! __EXTERN int console_input_status __PROTO((int));
- ! __EXTERN unsigned int console_read_byte __PROTO((int));
- ! __EXTERN void console_write_byte __PROTO((int, int));
- !
- ! __EXTERN time_t dostime __PROTO((time_t));
- ! __EXTERN time_t _unixtime __PROTO((unsigned int, unsigned int));
- !
- ! __EXTERN char * findfile __PROTO((char *, char *, char **));
- !
- ! __EXTERN char * _itoa __PROTO((int, char *, int));
- ! __EXTERN char * _ltoa __PROTO((long, char *, int));
- ! __EXTERN char * _ultoa __PROTO((unsigned long, char *, int));
- !
- ! __EXTERN int _doprnt __PROTO((FILE *, const char *, __VA_LIST__));
- !
- ! __EXTERN long get_sysvar __PROTO((void *var));
- ! __EXTERN void set_sysvar_to_long __PROTO((void *var, long val));
- !
- ! __EXTERN __EXITING __exit __PROTO((long status));
- !
- ! /* from the TOS GCC library */
- ! /* 5/5/92 sb -- definitions needed in malloc.c and realloc.c */
- !
- ! struct mem_chunk
- ! {
- ! long valid;
- ! #define VAL_FREE 0xf4ee0abc
- ! #define VAL_ALLOC 0xa11c0abc
- !
- ! struct mem_chunk *next;
- ! unsigned long size;
- ! };
- !
- ! /* linked list of free blocks */
- !
- ! __EXTERN struct mem_chunk _mchunk_free_list;
-
- #endif /* _LIB_H */
- *** 1.13 1992/01/29 20:58:29
- --- localtim.c 1992/06/03 14:49:22
- ***************
- *** 39,45 ****
- mth_start[13] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
-
- static time_t tzoffset __PROTO((char *s, int *hasdst));
- ! static int indst __PROTO((const struct tm *t));
-
- static int dst = -1; /* whether dst holds in current timezone */
-
- --- 39,45 ----
- mth_start[13] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
-
- static time_t tzoffset __PROTO((char *s, int *hasdst));
- ! static int indst __PROTO((long secs, const struct tm *t));
-
- static int dst = -1; /* whether dst holds in current timezone */
-
- ***************
- *** 54,61 ****
- * returned by localtime() and convert it into the standard representation
- * (as seconds since midnight Jan. 1 1970, GMT).
- *
- ! * Note that time() sends us such a structure with tm_yday undefined, so
- ! * we shouldn't count on tm_yday being correct.
- */
-
- time_t
- --- 54,61 ----
- * returned by localtime() and convert it into the standard representation
- * (as seconds since midnight Jan. 1 1970, GMT).
- *
- ! * Note that time() sends us such a structure with tm_yday and tm_wday
- ! * undefined, so we shouldn't count on these being correct!
- */
-
- time_t
- ***************
- *** 82,89 ****
- tzset();
-
- s += _timezone;
- ! if (dst == 1 && indst(t))
- ! s -= 3600;
-
- return s;
- }
- --- 82,89 ----
- tzset();
-
- s += _timezone;
- ! if (dst == 1 && indst(s, t))
- ! s -= SECS_PER_HOUR;
-
- return s;
- }
- ***************
- *** 148,163 ****
- {
- static struct tm ltim;
- struct tm *stm;
- ! time_t offset; /* seconds between local time and GMT */
-
- tzset();
- ! offset = *t - _timezone;
- ! if(offset < 0) offset = 0; /* this is questionable */
- ! stm = _gmtime(&offset, <im);
- if (stm == NULL) return stm; /* check for illegal time */
- stm->tm_isdst = (dst == -1) ? -1 : 0;
-
- ! if (dst == 1 && indst((const struct tm *)stm)) { /* daylight savings time in effect */
- stm->tm_isdst = 1;
- if (++stm->tm_hour > 23) {
- stm->tm_hour -= 24;
- --- 148,163 ----
- {
- static struct tm ltim;
- struct tm *stm;
- ! time_t gmsecs; /*time in GMT */
-
- tzset();
- ! gmsecs = *t - _timezone;
- ! stm = _gmtime(&gmsecs, <im);
- if (stm == NULL) return stm; /* check for illegal time */
- stm->tm_isdst = (dst == -1) ? -1 : 0;
-
- ! if (dst == 1 && indst(*t, (const struct tm *)stm)) {
- ! /* daylight savings time in effect */
- stm->tm_isdst = 1;
- if (++stm->tm_hour > 23) {
- stm->tm_hour -= 24;
- ***************
- *** 170,176 ****
- }
- }
- }
- ! DEBUG_TM("localtime", stm);
- return stm;
- }
-
- --- 170,176 ----
- }
- }
- }
- ! DEBUG_TM("localtime", stm);
- return stm;
- }
-
- ***************
- *** 302,310 ****
- */
-
- static
- ! int indst(t)
- const struct tm *t;
- {
- if (t->tm_mon == 3) { /* April */
- /* before 1987, see if there's another sunday in the month */
- if (t->tm_year < 87 && t->tm_wday + 30 - t->tm_mday < 7)
- --- 302,318 ----
- */
-
- static
- ! int indst(s, t)
- ! long s;
- const struct tm *t;
- {
- + int wkday;
- +
- + if (t->tm_wday >= 0)
- + wkday = t->tm_wday;
- + else
- + wkday = ((s / SECS_PER_DAY) + 4) % 7;
- +
- if (t->tm_mon == 3) { /* April */
- /* before 1987, see if there's another sunday in the month */
- if (t->tm_year < 87 && t->tm_wday + 30 - t->tm_mday < 7)
- *** 1.7 1992/03/22 21:57:30
- --- lseek.c 1992/06/03 14:49:22
- ***************
- *** 2,17 ****
- #include <stdio.h>
- #include <errno.h>
- #include <osbind.h>
- - #include <unistd.h>
- #include <memory.h>
- #include <string.h>
- #include "lib.h"
- - #ifndef _COMPILER_H
- - #include <compiler.h>
- - #endif
-
- ! static long _real_lseek __PROTO((int h, long where, int how));
- !
-
- static long _real_lseek(h, where, how)
- int h;
- --- 2,17 ----
- #include <stdio.h>
- #include <errno.h>
- #include <osbind.h>
- #include <memory.h>
- #include <string.h>
- + #include <unistd.h>
- #include "lib.h"
-
- ! #ifdef __GNUC__
- ! # ifndef alloca
- ! # define alloca __builtin_alloca
- ! # endif
- ! #endif
-
- static long _real_lseek(h, where, how)
- int h;
- ***************
- *** 67,73 ****
- offset = 256;
- if((current_pos = _write(handle, buf, offset)) != offset)
- return((current_pos > 0) ? (new_pos + current_pos) :
- ! new_pos); /* errno set by _write */
- new_pos += offset;
- }
- return(new_pos);
- --- 67,73 ----
- offset = 256;
- if((current_pos = _write(handle, buf, offset)) != offset)
- return((current_pos > 0) ? (new_pos + current_pos) :
- ! new_pos); /* errno set by write */
- new_pos += offset;
- }
- return(new_pos);
- *** 1.6 1991/04/26 03:42:08
- --- ltoa.c 1992/06/03 14:49:23
- ***************
- *** 1,4 ****
- --- 1,5 ----
- #include <string.h>
- + #include "lib.h"
-
- #ifdef __STRICT_ANSI__
- # ifdef __GNUC__
- *** 1.20 1992/03/06 19:19:47
- --- malloc.c 1992/06/03 14:49:23
- ***************
- *** 2,13 ****
- --- 2,17 ----
- /* malloc, free, realloc: dynamic memory allocation */
- /* ERS: added mlalloc, relalloc, etc. for 16 bit compilers. Changed
- argument of malloc, etc., to size_t (per ANSI draft). */
- + /* 5/2/92 sb -- modified for Heat-n-Serve C to accomodate its 16-bit size_t */
- + /* 5/5/92 sb -- split off realloc() & calloc() to reduce library drag */
-
- #include <stddef.h> /* for size_t */
- + #include <stdlib.h>
- #include <memory.h>
- #include <string.h>
- #include <assert.h>
- #include <unistd.h>
- + #include "lib.h"
-
- extern long _stksize;
-
- ***************
- *** 20,47 ****
- gets screwed on a 1M machine otherwise (stack/heap clash)
- */
-
- ! struct mem_chunk
- ! {
- ! long valid;
- ! #define VAL_FREE 0xf4ee0abc
- ! #define VAL_ALLOC 0xa11c0abc
- !
- ! struct mem_chunk *next;
- ! long size;
- ! };
-
- ! /* linked list of free blocks */
-
- - static struct mem_chunk _mchunk_free_list = { VAL_FREE, NULL, 0L };
- -
- /* flag to control zero'ing of malloc'ed chunks */
- static int _ZeroMallocs = 0;
-
-
- ! asm(".stabs \"_mlalloc\",5,0,0,_malloc"); /* dept of clean tricks */
-
- ! void * malloc(n)
- ! size_t n;
- {
- struct mem_chunk *p, *q;
- long sz;
- --- 24,45 ----
- gets screwed on a 1M machine otherwise (stack/heap clash)
- */
-
- ! /* linked list of free blocks struct defined in lib.h */
-
- ! struct mem_chunk _mchunk_free_list = { VAL_FREE, NULL, 0L };
-
- /* flag to control zero'ing of malloc'ed chunks */
- static int _ZeroMallocs = 0;
-
- + __EXTERN void _bzero __PROTO((void *, unsigned long));
- + __EXTERN void *_sbrk __PROTO((long));
-
- ! #ifdef __GNUC__
- ! asm(".stabs \"_malloc\",5,0,0,__malloc"); /* dept of clean tricks */
- ! #endif
-
- ! void * _malloc(n)
- ! unsigned long n;
- {
- struct mem_chunk *p, *q;
- long sz;
- ***************
- *** 71,77 ****
- if (MINHUNK < MAXHUNK)
- MINHUNK *= 2;
- }
- ! q = (struct mem_chunk * )sbrk(sz);
-
- if (((long)q) == -1) /* can't alloc any more? */
- return(NULL);
- --- 69,75 ----
- if (MINHUNK < MAXHUNK)
- MINHUNK *= 2;
- }
- ! q = (struct mem_chunk * )_sbrk(sz);
-
- if (((long)q) == -1) /* can't alloc any more? */
- return(NULL);
- ***************
- *** 102,108 ****
- q->next = NULL;
- q++; /* hand back ptr to after chunk desc */
- if(_ZeroMallocs != 0)
- ! bzero((void *)q, (long)(n - sizeof(struct mem_chunk)));
-
- return((void * )q);
- }
- --- 100,106 ----
- q->next = NULL;
- q++; /* hand back ptr to after chunk desc */
- if(_ZeroMallocs != 0)
- ! _bzero((void *)q, (long)(n - sizeof(struct mem_chunk)));
-
- return((void * )q);
- }
- ***************
- *** 184,272 ****
- }
- }
-
- - asm(".stabs \"_relalloc\",5,0,0,_realloc");
- -
- - void * realloc(_r, n)
- - void *_r;
- - size_t n;
- - {
- - struct mem_chunk *p, *q, *r = (struct mem_chunk *) _r;
- - long sz;
- -
- - /* obscure features: realloc(NULL,n) is the same as malloc(n)
- - * realloc(p, 0) is the same as free(p)
- - */
- - if (!r)
- - return malloc(n);
- - if (n == 0) {
- - free(_r);
- - return NULL;
- - }
- - p = r - 1;
- - sz = (n + sizeof(struct mem_chunk) + 7) & ~7;
- -
- - if (p->size > sz)
- - { /* block too big, split in two */
- - q = (struct mem_chunk * )(((long) p) + sz);
- - q->size = p->size - sz;
- - q->valid = VAL_ALLOC;
- - free(q + 1);
- - p->size = sz;
- - }
- - else
- - if (p->size < sz)
- - { /* block too small, get new one */
- - struct mem_chunk *s, *t;
- - q = &_mchunk_free_list;
- - t = _mchunk_free_list.next;
- - while (t != NULL && t < p)
- - {
- - q = t;
- - t = t->next;
- - }
- -
- - /* merge after if possible */
- - s = (struct mem_chunk * )(((long) p) + p->size);
- - if (t != NULL && s >= t && p->size + t->size >= sz)
- - {
- - assert(s == t);
- - p->size += t->size;
- - q->next = t->next;
- - t->size = 0;
- - t->next = NULL;
- - }
- - else
- - {
- - q = (struct mem_chunk * )malloc(n);
- - if (q != NULL)
- - {
- - n = p->size - sizeof(struct mem_chunk);
- - bcopy(r, q, n);
- - free(r); /* free r only if we got a new block */
- - }
- - /* else we could try to mlalloc the rest and hope that we can merge */
- - r = q;
- - }
- - }
- - /* else current block will do just fine */
- - return((void * )r);
- - }
- -
- - asm(".stabs \"_clalloc\",5,0,0,_calloc");
- - void * calloc(n, sz)
- - size_t n, sz;
- - {
- - void *r;
- - size_t total;
- -
- - total = n * sz;
- - if ((r = malloc(total)) != NULL)
- - {
- - bzero(r, total);
- - }
- - return(r);
- - }
- -
- /*
- * Set zero block after malloc flag
- */
- --- 182,187 ----
- ***************
- *** 284,286 ****
- --- 199,209 ----
- {
- MAXHUNK = MINHUNK = siz;
- }
- +
- + #ifndef __GNUC__
- + void * malloc(n)
- + size_t n;
- + {
- + return _malloc((unsigned long) n);
- + }
- + #endif
- *** 1.12 1992/03/10 15:11:47
- --- mktemp.c 1992/06/03 14:49:23
- ***************
- *** 11,18 ****
- #include <errno.h>
- #include "lib.h"
-
- - #define __MINT__
- - #include <mintbind.h>
- extern int __mint; /* 0 for TOS, MiNT version number otherwise */
-
- #define TEN_MUL(X) ((((X) << 2) + (X)) << 1)
- --- 11,16 ----
- ***************
- *** 38,45 ****
- /* we need 5 X's for this: up to 3 for the pid, and up to 2 for the
- extra number */
- if (__mint && nx > 4 && startat < 256) {
- ! int pid = Pgetpid();
- ! (void) _itoa(pid, q, 10);
- while (*q) q++;
- (void) _itoa(startat++, q, 16);
- return pattern;
- --- 36,42 ----
- /* we need 5 X's for this: up to 3 for the pid, and up to 2 for the
- extra number */
- if (__mint && nx > 4 && startat < 256) {
- ! (void) _itoa(getpid(), q, 10);
- while (*q) q++;
- (void) _itoa(startat++, q, 16);
- return pattern;
- *** 1.8 1991/06/11 14:56:53
- --- perror.c 1992/06/03 14:49:24
- ***************
- *** 8,106 ****
- #include <errno.h>
- #include <string.h>
-
- -
- - static char nullstr[] = "";
- -
- -
- - char *sys_errlist[] =
- - {
- - "OK", /* 0 */
- - "error", /* 1 */
- - "drive not ready", /* 2 */
- - "unknown command", /* 3 */
- - "crc error", /* 4 */
- - "bad request", /* 5 */
- - "seek error", /* 6 */
- - "unknown media", /* 7 */
- - "sector not found", /* 8 */
- - "out of paper", /* 9 */
- - "write failure", /* 10 */
- - "read failure", /* 11 */
- - "general mishap", /* 12 */
- - "media write protected", /* 13 */
- - "media changed", /* 14 */
- - "unknown device", /* 15 */
- - "bad sectors on format", /* 16 */
- - "disk swap request", /* 17 */
- - nullstr, /* 18 */
- - nullstr, /* 19 */
- - nullstr, /* 20 */
- - nullstr, /* 21 */
- - nullstr, /* 22 */
- - nullstr, /* 23 */
- - nullstr, /* 24 */
- - nullstr, /* 25 */
- - nullstr, /* 26 */
- - nullstr, /* 27 */
- - nullstr, /* 28 */
- - nullstr, /* 29 */
- - nullstr, /* 30 */
- - nullstr, /* 31 */
- - "invalid function number", /* 32 */
- - "file not found", /* 33 */
- - "path not found", /* 34 */
- - "no more handles", /* 35 */
- - "access denied", /* 36 */
- - "invalid handle", /* 37 */
- - nullstr, /* 38 */
- - "out of memory", /* 39 */
- - "invalid memory block", /* 40 */
- - nullstr, /* 41 */
- - nullstr, /* 42 */
- - nullstr, /* 43 */
- - nullstr, /* 44 */
- - nullstr, /* 45 */
- - "invalid drive id", /* 46 */
- - nullstr, /* 47 */
- - "rename across drives", /* 48 */
- - "no more files", /* 49 */
- - nullstr, /* 50 */
- - nullstr, /* 51 */
- - nullstr, /* 52 */
- - nullstr, /* 53 */
- - nullstr, /* 54 */
- - nullstr, /* 55 */
- - nullstr, /* 56 */
- - nullstr, /* 57 */
- - nullstr, /* 58 */
- - nullstr, /* 59 */
- - nullstr, /* 60 */
- - nullstr, /* 61 */
- - "domain error", /* 62 */
- - "range error", /* 63 */
- - "range error/bad argument", /* 64 */
- - "internal error", /* 65 */
- - "bad executable format", /* 66 */
- - "memory block growth failure", /* 67 */
- - nullstr, /* 68 */
- - nullstr, /* 69 */
- - nullstr, /* 70 */
- - nullstr, /* 71 */
- - nullstr, /* 72 */
- - nullstr, /* 73 */
- - nullstr, /* 74 */
- - nullstr, /* 75 */
- - nullstr, /* 76 */
- - nullstr, /* 77 */
- - nullstr, /* 78 */
- - nullstr, /* 79 */
- - "file already exists", /* 80 */
- - "name too long", /* 81 */
- - "not a tty", /* 82 */
- - };
- -
- - int sys_nerr = (int)(sizeof(sys_errlist) / sizeof(sys_errlist[0]));
- -
- void perror(msg)
- const char *msg;
- {
- --- 8,13 ----
- ***************
- *** 109,115 ****
- fputs(msg, stderr);
- fputs(": ", stderr);
- }
- !
- ! fputs(strerror(errno), stderr);
- fputs(".\n", stderr);
- }
- --- 16,22 ----
- fputs(msg, stderr);
- fputs(": ", stderr);
- }
- ! if(msg = strerror(errno))
- ! fputs(msg, stderr);
- fputs(".\n", stderr);
- }
- *** 1.4 1991/04/12 18:19:53
- --- psignal.c 1992/06/03 14:49:24
- ***************
- *** 5,11 ****
-
- #include <signal.h>
- #include <siglist.h>
- - #include <unistd.h>
- #include <string.h>
- #include "lib.h"
-
- --- 5,10 ----
- ***************
- *** 14,27 ****
- int sig;
- const char *prefix;
- {
- ! write(2, "\r\n", 2);
- if(prefix && *prefix) {
- ! write(2, prefix, strlen(prefix));
- ! write(2, ": ", 2);
- }
- if (sig > 0 && sig < NSIG)
- ! write(2, sys_siglist[sig], (int)strlen(sys_siglist[sig]));
- else
- ! write(2, "unknown signal", 14);
- ! write(2, "\r\n", 2);
- }
- --- 13,26 ----
- int sig;
- const char *prefix;
- {
- ! _write(2, "\r\n", 2L);
- if(prefix && *prefix) {
- ! _write(2, prefix, (long)strlen(prefix));
- ! _write(2, ": ", 2L);
- }
- if (sig > 0 && sig < NSIG)
- ! _write(2, sys_siglist[sig], (long)strlen(sys_siglist[sig]));
- else
- ! _write(2, "unknown signal", 14L);
- ! _write(2, "\r\n", 2L);
- }
- *** 1.11 1992/03/06 19:19:47
- --- qsort.c 1992/06/03 14:49:25
- ***************
- *** 50,59 ****
- #define STACK_NOT_EMPTY \
- (stack < top)
-
- ! static void swap __PROTO((unsigned char *, unsigned char *, size_t));
- ! static void Move __PROTO((unsigned char *, unsigned char *, size_t));
- ! static void insert_sort __PROTO((void *, void *, size_t, int (*)(const void *, const void *)));
- ! static void *find_pivot __PROTO((void *, void *, size_t, int (*)(const void *, const void *)));
-
- /* Discontinue quicksort algorithm when partition gets below this size. */
-
- --- 50,59 ----
- #define STACK_NOT_EMPTY \
- (stack < top)
-
- ! INLINE static void swap __PROTO((unsigned char *, unsigned char *, size_t));
- ! INLINE static void Move __PROTO((unsigned char *, unsigned char *, size_t));
- ! INLINE static void insert_sort __PROTO((void *, void *, size_t, int (*)(const void *, const void *)));
- ! INLINE static void *find_pivot __PROTO((void *, void *, size_t, int (*)(const void *, const void *)));
-
- /* Discontinue quicksort algorithm when partition gets below this size. */
-
- *** 1.6 1992/03/06 19:19:47
- --- random.c 1992/06/03 14:49:25
- ***************
- *** 39,45 ****
- * zeroeth element of the array is the type of R.N.G. being used (small
- * integer); the remainder of the array is the state information for the
- * R.N.G. Thus, 32 bytes of state information will give 7 longs worth of
- ! * state information, which will allow a degree seven polynomial. (Note: the
- * zeroeth word of state information also has some other information stored
- * in it -- see setstate() for details).
- * The random number generation technique is a linear feedback shift register
- --- 39,45 ----
- * zeroeth element of the array is the type of R.N.G. being used (small
- * integer); the remainder of the array is the state information for the
- * R.N.G. Thus, 32 bytes of state information will give 7 longs worth of
- ! * state information, which will allow a degree seven polynomial. (Note: the
- * zeroeth word of state information also has some other information stored
- * in it -- see setstate() for details).
- * The random number generation technique is a linear feedback shift register
- ***************
- *** 121,133 ****
- */
-
- static long randtbl[ DEG_3 + 1 ] = { TYPE_3,
- ! 0x9a319039, 0x32d9c024, 0x9b663182, 0x5da1f342,
- ! 0xde3b81e0, 0xdf0a6fb5, 0xf103bc02, 0x48f340fb,
- ! 0x7449e56b, 0xbeb1dbb0, 0xab5c5918, 0x946554fd,
- ! 0x8c2e680f, 0xeb3d799f, 0xb11ee0b7, 0x2d436b86,
- ! 0xda672e2a, 0x1588ca88, 0xe369735d, 0x904f35f7,
- ! 0xd7158fd6, 0x6fa6f051, 0x616e6b96, 0xac94efdc,
- ! 0x36413f93, 0xc622c298, 0xf5a42ab8, 0x8a88d77b,
- 0xf5ad9d0e, 0x8999220b, 0x27fb47b9 };
-
- /*
- --- 121,133 ----
- */
-
- static long randtbl[ DEG_3 + 1 ] = { TYPE_3,
- ! 0x9a319039, 0x32d9c024, 0x9b663182, 0x5da1f342,
- ! 0xde3b81e0, 0xdf0a6fb5, 0xf103bc02, 0x48f340fb,
- ! 0x7449e56b, 0xbeb1dbb0, 0xab5c5918, 0x946554fd,
- ! 0x8c2e680f, 0xeb3d799f, 0xb11ee0b7, 0x2d436b86,
- ! 0xda672e2a, 0x1588ca88, 0xe369735d, 0x904f35f7,
- ! 0xd7158fd6, 0x6fa6f051, 0x616e6b96, 0xac94efdc,
- ! 0x36413f93, 0xc622c298, 0xf5a42ab8, 0x8a88d77b,
- 0xf5ad9d0e, 0x8999220b, 0x27fb47b9 };
-
- /*
- ***************
- *** 182,198 ****
- * values produced by this routine.
- */
-
- ! void srandom( x )
-
- ! unsigned int x;
- {
- ! register int i;
- ! long random(void);
-
- if( rand_type == TYPE_0 ) {
- state[ 0 ] = x;
- }
- else {
- state[ 0 ] = x;
- for( i = 1; i < rand_deg; i++ ) {
- state[i] = 1103515245*state[i - 1] + 12345;
- --- 182,200 ----
- * values produced by this routine.
- */
-
- ! void /* ++ERS: Berkeley didn't have this */
- ! srandom( x )
-
- ! unsigned x;
- {
- ! register int i, j;
- ! long random();
-
- if( rand_type == TYPE_0 ) {
- state[ 0 ] = x;
- }
- else {
- + j = 1;
- state[ 0 ] = x;
- for( i = 1; i < rand_deg; i++ ) {
- state[i] = 1103515245*state[i - 1] + 12345;
- ***************
- *** 221,237 ****
- * Returns a pointer to the old state.
- */
-
- - #if !__STDC__
- - /* you need an ansi C compatible pre-processor jack! */
- - #else
- - # define STR(s) # s
- - # define XSTR(s) STR(s)
- - #endif
- -
- char *
- initstate( seed, arg_state, n )
-
- ! unsigned int seed; /* seed for R. N. G. */
- char *arg_state; /* pointer to state array */
- int n; /* # bytes of state info */
- {
- --- 223,232 ----
- * Returns a pointer to the old state.
- */
-
- char *
- initstate( seed, arg_state, n )
-
- ! unsigned seed; /* seed for R. N. G. */
- char *arg_state; /* pointer to state array */
- int n; /* # bytes of state info */
- {
- ***************
- *** 241,252 ****
- else state[ -1 ] = MAX_TYPES*(rptr - state) + rand_type;
- if( n < BREAK_1 ) {
- if( n < BREAK_0 ) {
- - /*
- fprintf( stderr, "initstate: not enough state (%d bytes) with which to do jack; ignored.\n", n );
- ! */
- ! fputs( "initstate: not enough state (less than " XSTR(BREAK_0)
- ! " bytes)\nwith which to do jack; ignored.\n", stderr);
- ! return NULL;
- }
- rand_type = TYPE_0;
- rand_deg = DEG_0;
- --- 236,243 ----
- else state[ -1 ] = MAX_TYPES*(rptr - state) + rand_type;
- if( n < BREAK_1 ) {
- if( n < BREAK_0 ) {
- fprintf( stderr, "initstate: not enough state (%d bytes) with which to do jack; ignored.\n", n );
- ! return 0;
- }
- rand_type = TYPE_0;
- rand_deg = DEG_0;
- ***************
- *** 324,335 ****
- break;
-
- default:
- - /**
- fprintf( stderr, "setstate: state info has been munged; not changed.\n" );
- - **/
- - fputs("setstate: state info has been munged; not changed.\n",
- - stderr);
- -
- }
- state = &new_state[ 1 ];
- if( rand_type != TYPE_0 ) {
- --- 315,321 ----
- ***************
- *** 361,367 ****
- random()
- {
- long i;
- !
- if( rand_type == TYPE_0 ) {
- i = state[0] = ( state[0]*1103515245 + 12345 )&0x7fffffff;
- }
- --- 347,353 ----
- random()
- {
- long i;
- !
- if( rand_type == TYPE_0 ) {
- i = state[0] = ( state[0]*1103515245 + 12345 )&0x7fffffff;
- }
- ***************
- *** 378,381 ****
- }
- return( i );
- }
- -
- --- 364,366 ----
- *** 1.11 1992/04/06 19:33:32
- --- sbrk.c 1992/06/03 14:49:26
- ***************
- *** 15,20 ****
- --- 15,26 ----
- brain damage, even when pointed out to them. sigh!)
- */
-
- + /*
- + * support heat and serve C -- whose author continues to be adamant about
- + * size_t -- big sigh!
- + */
- +
- + #include <stddef.h>
- #include <osbind.h>
- #include <unistd.h>
- #include <errno.h>
- ***************
- *** 24,36 ****
- extern short _split_mem;
-
- static void * HeapAlloc( sz )
- ! size_t sz ;
- {
- char slush [64];
- register void *sp;
-
- sp = (void *)slush;
- ! sz = (sz + 7) & ~((size_t)7L); /* round up request size next octet */
-
- if ( sp < (void *)((char *)_heapbase + sz) )
- {
- --- 30,42 ----
- extern short _split_mem;
-
- static void * HeapAlloc( sz )
- ! unsigned long sz ;
- {
- char slush [64];
- register void *sp;
-
- sp = (void *)slush;
- ! sz = (sz + 7) & ~((unsigned long)7L); /* round up request size next octet */
-
- if ( sp < (void *)((char *)_heapbase + sz) )
- {
- ***************
- *** 43,52 ****
- return( sp );
- }
-
- ! asm(".stabs \"_sbrk\",5,0,0,_lsbrk"); /* dept of clean tricks */
-
- /* provided for compilers with sizeof(int) == 2 */
- ! void *lsbrk(long n)
- {
- void *rval;
-
- --- 49,62 ----
- return( sp );
- }
-
- ! #ifndef __GNUC__
- ! asm(".stabs \"_sbrk\",5,0,0,__sbrk"); /* dept of clean tricks */
- ! asm(".stabs \"_lsbrk\",5,0,0,__sbrk"); /* dept of clean tricks */
- ! #endif
-
- /* provided for compilers with sizeof(int) == 2 */
- ! void *_sbrk(n)
- ! long n;
- {
- void *rval;
-
- ***************
- *** 64,70 ****
- if(_split_mem)
- { /* now switch over to own heap for further requests, including this one */
- _split_mem = 0;
- ! return lsbrk(n);
- }
- errno = ENOMEM;
- rval = (void *)(-1L);
- --- 74,80 ----
- if(_split_mem)
- { /* now switch over to own heap for further requests, including this one */
- _split_mem = 0;
- ! return _sbrk(n);
- }
- errno = ENOMEM;
- rval = (void *)(-1L);
- ***************
- *** 71,73 ****
- --- 81,97 ----
- }
- return rval;
- }
- +
- + #ifndef __GNUC__
- + void *sbrk(x)
- + int x;
- + {
- + return _sbrk((long)x);
- + }
- +
- + void *lsbrk(x)
- + long x;
- + {
- + return _sbrk(x);
- + }
- + #endif
- *** 1.8 1991/05/23 14:43:17
- --- setbuf.c 1992/06/03 14:49:26
- ***************
- *** 35,42 ****
- * should stream be flushed before change?? i think so.
- * ++jrb
- */
- - #define __SRC__
- - #include <unistd.h>
-
- void setlinebuf(fp)
- register FILE *fp;
- --- 35,40 ----
- *** 1.2 1991/04/12 18:19:53
- --- sgtty.c 1992/06/03 14:49:27
- ***************
- *** 3,9 ****
- */
-
- #include <ioctl.h>
- - #include <unistd.h>
-
- int
- stty(fd, _tty)
- --- 3,8 ----
- *** 1.7 1992/03/06 19:19:47
- --- sprintf.c 1992/06/03 14:49:27
- ***************
- *** 1,6 ****
- --- 1,7 ----
- #include <stdarg.h>
- #include <stdio.h>
- #include <limits.h>
- + #include "lib.h"
-
- #ifdef __SOZOBON__ /* Electronic brain... */
- static FILE dummyf =
- *** 1.7 1991/06/23 17:07:09
- --- strchr.c 1992/06/03 14:49:28
- ***************
- *** 5,11 ****
- --- 5,21 ----
- /*
- * strchr - find first occurrence of a character in a string
- */
- + #ifdef __GNUC__
- asm(".stabs \"_index\",5,0,0,_strchr"); /* dept of clean tricks */
- + #else
- + char *
- + index(s, charwanted)
- + const char *s;
- + char charwanted;
- + {
- + return strchr(s, charwanted);
- + }
- + #endif
-
- char * /* found char, or NULL if none */
- strchr(s, charwanted)
- *** 1.4 1991/05/23 14:43:17
- --- strerror.c 1992/06/03 14:49:29
- ***************
- *** 1,6 ****
- --- 1,104 ----
- /* from Henry Spencer's stringlib */
- #include <string.h>
-
- + static char nullstr[] = "unknown error";
- +
- + char *sys_errlist[] =
- + {
- + "OK", /* 0 */
- + "error", /* 1 */
- + "drive not ready", /* 2 */
- + "unknown command", /* 3 */
- + "crc error", /* 4 */
- + "bad request", /* 5 */
- + "seek error", /* 6 */
- + "unknown media", /* 7 */
- + "sector not found", /* 8 */
- + "out of paper", /* 9 */
- + "write failure", /* 10 */
- + "read failure", /* 11 */
- + "general mishap", /* 12 */
- + "media write protected", /* 13 */
- + "media changed", /* 14 */
- + "unknown device", /* 15 */
- + "bad sectors on format", /* 16 */
- + "disk swap request", /* 17 */
- + nullstr, /* 18 */
- + nullstr, /* 19 */
- + nullstr, /* 20 */
- + nullstr, /* 21 */
- + nullstr, /* 22 */
- + nullstr, /* 23 */
- + nullstr, /* 24 */
- + nullstr, /* 25 */
- + nullstr, /* 26 */
- + nullstr, /* 27 */
- + nullstr, /* 28 */
- + nullstr, /* 29 */
- + nullstr, /* 30 */
- + nullstr, /* 31 */
- + "invalid function number", /* 32 */
- + "file not found", /* 33 */
- + "path not found", /* 34 */
- + "no more handles", /* 35 */
- + "access denied", /* 36 */
- + "invalid handle", /* 37 */
- + nullstr, /* 38 */
- + "out of memory", /* 39 */
- + "invalid memory block", /* 40 */
- + nullstr, /* 41 */
- + nullstr, /* 42 */
- + nullstr, /* 43 */
- + nullstr, /* 44 */
- + nullstr, /* 45 */
- + "invalid drive id", /* 46 */
- + nullstr, /* 47 */
- + "rename across drives", /* 48 */
- + "no more files", /* 49 */
- + nullstr, /* 50 */
- + nullstr, /* 51 */
- + nullstr, /* 52 */
- + nullstr, /* 53 */
- + nullstr, /* 54 */
- + nullstr, /* 55 */
- + nullstr, /* 56 */
- + nullstr, /* 57 */
- + nullstr, /* 58 */
- + nullstr, /* 59 */
- + nullstr, /* 60 */
- + nullstr, /* 61 */
- + nullstr, /* 62 */
- + nullstr, /* 63 */
- + "range error/bad argument", /* 64 */
- + "internal error", /* 65 */
- + "bad executable format", /* 66 */
- + "memory block growth failure", /* 67 */
- + nullstr, /* 68 */
- + nullstr, /* 69 */
- + nullstr, /* 70 */
- + nullstr, /* 71 */
- + nullstr, /* 72 */
- + nullstr, /* 73 */
- + nullstr, /* 74 */
- + nullstr, /* 75 */
- + nullstr, /* 76 */
- + nullstr, /* 77 */
- + nullstr, /* 78 */
- + nullstr, /* 79 */
- + "too many symbolic links", /* 80 */
- + nullstr, /* 81 */
- + nullstr, /* 82 */
- + nullstr, /* 83 */
- + nullstr, /* 84 */
- + "file already exists", /* 85 */
- + "name too long", /* 86 */
- + "not a tty", /* 87 */
- + "range error", /* 88 */
- + "domain error" /* 89 */
- + };
- +
- + int sys_nerr = (int)(sizeof(sys_errlist)/sizeof(sys_errlist[0]));
- +
- /*
- * strerror - map error number to descriptive string
- *
- ***************
- *** 16,20 ****
- if (errnum >= 0 && errnum < sys_nerr)
- return(sys_errlist[errnum]);
- else
- ! return("unknown error");
- }
- --- 114,118 ----
- if (errnum >= 0 && errnum < sys_nerr)
- return(sys_errlist[errnum]);
- else
- ! return(nullstr);
- }
- *** 1.5 1992/04/13 15:50:45
- --- strftime.c 1992/06/03 14:49:29
- ***************
- *** 196,205 ****
- strftime(buf, sizeof buf, "%H:%M:%S", ts);
- break;
- #endif
- - default:
- - buf[0] = q;
- - buf[1] = 0;
- - break;
- }
-
- if (num + (len = strlen(putstr)) >= maxsize)
- --- 196,201 ----
- *** 1.5 1991/04/12 18:19:53
- --- strlen.c 1992/06/03 14:49:29
- ***************
- *** 13,18 ****
-
- if (!scan) return 0;
- while (*scan++ != '\0')
- ! continue;
- return (size_t)((long)scan - (long)start);
- }
- --- 13,18 ----
-
- if (!scan) return 0;
- while (*scan++ != '\0')
- ! continue;
- return (size_t)((long)scan - (long)start);
- }
- *** 1.7 1991/06/23 17:07:09
- --- strrchr.c 1992/06/03 14:49:31
- ***************
- *** 4,10 ****
- --- 4,20 ----
- /*
- * strrchr - find last occurrence of a character in a string
- */
- + #ifdef __GNUC__
- asm(".stabs \"_rindex\",5,0,0,_strrchr"); /* dept of clean tricks */
- + #else
- + char *
- + rindex(s, charwanted)
- + const char *s;
- + char charwanted;
- + {
- + return strrchr(s, charwanted);
- + }
- + #endif
-
- char * /* found char, or NULL if none */
- strrchr(s, charwanted)
- *** 1.16 1992/04/06 19:33:32
- --- system.c 1992/06/03 14:49:32
- ***************
- *** 3,9 ****
- *
- * Written by Eric R. Smith and placed in the public domain.
- *
- ! * Modified by Allan Pratt to call unx2dos on redirect file names
- * and to call spawnvp() without calling fork() -- why bother?
- *
- * Modified by Frank Ridderbusch in _parseargs() to handle the case
- --- 3,9 ----
- *
- * Written by Eric R. Smith and placed in the public domain.
- *
- ! * Modified by Allan Pratt to call _unx2dos on redirect file names
- * and to call spawnvp() without calling fork() -- why bother?
- *
- * Modified by Frank Ridderbusch in _parseargs() to handle the case
- ***************
- *** 12,18 ****
- *
- */
-
- ! #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- #include <stdlib.h>
- --- 12,18 ----
- *
- */
-
- ! #include <limits.h>
- #include <string.h>
- #include <ctype.h>
- #include <stdlib.h>
- ***************
- *** 23,34 ****
- #include <unistd.h>
- #include "lib.h"
-
- - #ifndef _COMPILER_H
- - #include <compiler.h>
- - #endif
- -
- #define isquote(c) ((c) == '\"' || (c) == '\'' || (c) == '`')
- ! #define ARG_ERR ( (Argentry *) -1L )
-
- /* struct. used to build a list of arguments for the command */
-
- --- 23,30 ----
- #include <unistd.h>
- #include "lib.h"
-
- #define isquote(c) ((c) == '\"' || (c) == '\'' || (c) == '`')
- ! #define ARG_ERR ( (Argentry *) -1 )
-
- /* struct. used to build a list of arguments for the command */
-
- ***************
- *** 37,45 ****
- char string[1];
- } Argentry;
-
- - static Argentry *_argalloc __PROTO((const char *s));
- - static void _argfree __PROTO((Argentry *p));
- - static Argentry *_parseargs __PROTO((const char *s));
-
- /* allocate an Argentry that will hold the string "s" */
-
- --- 33,38 ----
- ***************
- *** 82,92 ****
- const char *s;
- {
- Argentry *cur, *res;
- - #ifdef __SOZOBON__ /* This is actually the legal way, */
- char buf[1024];
- - #else
- - char buf[BUFSIZ]; /* because this features a cast. */
- - #endif
- char *t, quote;
-
- res = cur = _argalloc("");
- --- 75,81 ----
- ***************
- *** 136,142 ****
- char *infile, *outfile;
- int infd = 0, outfd = 1, append = 0;
- int oldin = 0, oldout = 1; /* hold the Fdup'd in, out */
- ! char path[FILENAME_MAX];
- int retval;
-
- if (!s) /* check for system() supported ?? */
- --- 125,131 ----
- char *infile, *outfile;
- int infd = 0, outfd = 1, append = 0;
- int oldin = 0, oldout = 1; /* hold the Fdup'd in, out */
- ! char path[PATH_MAX];
- int retval;
-
- if (!s) /* check for system() supported ?? */
- *** 1.4 1991/04/12 18:19:53
- --- time.c 1992/06/03 14:49:33
- ***************
- *** 3,18 ****
-
- #include <time.h>
- #include <osbind.h>
- - #include <unistd.h>
-
- static struct tm this_tm;
-
- /* unixtime: convert a DOS time/date pair into a unix time */
-
- ! time_t unixtime(dostime, dosdate)
- unsigned dostime, dosdate;
- {
- ! extern time_t mktime(const struct tm *);
- struct tm *stm = &this_tm;
-
- stm->tm_sec = (dostime & 31) << 1;
- --- 3,23 ----
-
- #include <time.h>
- #include <osbind.h>
-
- static struct tm this_tm;
- + int _dst;
-
- /* unixtime: convert a DOS time/date pair into a unix time */
- + /* in case people were wondering about whether or not DST is applicable
- + * right now, we set the external variable _dst to the value
- + * returned from mktime
- + */
-
- ! time_t
- ! _unixtime(dostime, dosdate)
- unsigned dostime, dosdate;
- {
- ! time_t t;
- struct tm *stm = &this_tm;
-
- stm->tm_sec = (dostime & 31) << 1;
- ***************
- *** 21,29 ****
- stm->tm_mday = dosdate & 31;
- stm->tm_mon = ((dosdate >> 5) & 15) - 1;
- stm->tm_year = 80 + ((dosdate >> 9) & 255);
-
- ! /* mktime expects a local time */
- ! return mktime(stm);
- }
-
- time_t time(t)
- --- 26,39 ----
- stm->tm_mday = dosdate & 31;
- stm->tm_mon = ((dosdate >> 5) & 15) - 1;
- stm->tm_year = 80 + ((dosdate >> 9) & 255);
- + stm->tm_isdst = -1; /* we don't know about DST */
- + stm->tm_wday = stm->tm_yday = -1; /* or about these */
-
- ! /* mktime expects a local time, which is what we're giving it */
- ! t = mktime(stm);
- !
- ! _dst = (stm->tm_isdst == 1) ? 1 : 0;
- ! return t;
- }
-
- time_t time(t)
- ***************
- *** 34,42 ****
-
- dostime = Tgettime();
- dosdate = Tgetdate();
- ! made = unixtime(dostime, dosdate);
- if (t)
- *t = made;
- return made;
- }
- -
- --- 44,51 ----
-
- dostime = Tgettime();
- dosdate = Tgetdate();
- ! made = _unixtime(dostime, dosdate);
- if (t)
- *t = made;
- return made;
- }
- *** 1.2 1989/07/17 02:24:36
- --- tmpfile.c 1992/06/03 14:49:33
- ***************
- *** 6,11 ****
- --- 6,13 ----
- #include <stdio.h>
- #include <stdlib.h>
-
- + extern int __mint;
- +
- typedef struct {
- char *name;
- FILE *fp;
- ***************
- *** 37,42 ****
- --- 39,54 ----
- free(junknam);
- return NULL;
- }
- +
- + /* in MiNT 0.9 and above, we can often unlink a file and continue to use
- + * it; some file systems may return EACCDN for unlinking an open file,
- + * in which case we use the old method of unlinking the file at exit
- + */
- + if (__mint >= 9) {
- + if (remove(junknam) == 0)
- + return junkfil;
- + }
- +
- if((++numtmps) == 0)
- file_to_delete = (FILE_RECORD *)malloc((size_t)sizeof(FILE_RECORD));
- else
- *** 1.7 1992/03/06 19:19:47
- --- tmpnam.c 1992/06/03 14:49:34
- ***************
- *** 1,27 ****
- /* tmpnam.c : return a temporary file name */
- /* written by Eric R. Smith and placed in the public domain */
- !
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- ! extern char *getenv(const char *), *mktemp(char *), *strcpy(char *, const char *),
- ! *strcat(char *, const char *);
-
- char *tmpnam(buf)
- char *buf;
- {
- char *tmpdir;
- !
- ! if (!buf && !(buf = (char *)malloc(L_tmpnam)))
- ! return NULL;
-
- ! if (!(tmpdir = getenv("TEMP")) && !(tmpdir = getenv("TMPDIR")))
- ! #ifdef UNIX
- ! tmpdir = "/tmp";
- ! #else
- tmpdir = ".";
- ! #endif
- ! (void) strcat(strcpy(buf, tmpdir), "\\__XXXXXX");
- return(mktemp(buf));
- }
- --- 1,40 ----
- /* tmpnam.c : return a temporary file name */
- /* written by Eric R. Smith and placed in the public domain */
- ! /**
- ! * - retuned name can be passed outside via system(); other programs
- ! * may not dig '/' as a path separator
- ! * - somehow more frugal in a memory use
- ! * (mj - October 1990)
- ! **/
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- ! static char pattern[] = "\\__XXXXXX";
-
- char *tmpnam(buf)
- char *buf;
- {
- char *tmpdir;
- ! size_t tlen;
- ! extern char *mktemp __PROTO((char *));
-
- ! if (!(tmpdir = getenv("TEMP")) && !(tmpdir = getenv("TMPDIR")) &&
- ! !(tmpdir = getenv("TMP")) && !(tmpdir = getenv("TEMPDIR")))
- tmpdir = ".";
- !
- ! tlen = strlen(tmpdir);
- !
- ! if (!buf) {
- ! size_t blen;
- !
- ! blen = tlen + sizeof(pattern);
- ! if (NULL == (buf = (char *) malloc(blen)))
- ! return NULL;
- ! }
- ! strcpy(buf, tmpdir);
- ! if (tmpdir[tlen-1] == '/' || tmpdir[tlen-1] == '\\')
- ! --tlen;
- ! strcpy(buf+tlen, pattern);
- return(mktemp(buf));
- }
- *** 1.8 1991/06/11 23:04:27
- --- utime.c 1992/06/03 14:49:34
- ***************
- *** 11,19 ****
- *
- */
-
- ! #include <stdio.h>
- ! #include <unistd.h>
- ! #include <support.h>
- #include <errno.h>
- #include <osbind.h>
- #include <assert.h>
- --- 11,19 ----
- *
- */
-
- ! #include <limits.h>
- ! #include <sys/types.h>
- ! #include <time.h>
- #include <errno.h>
- #include <osbind.h>
- #include <assert.h>
- ***************
- *** 25,31 ****
- time_t dostime(t)
- time_t t;
- {
- ! time_t time, date;
- struct tm *ctm;
-
- if (!(ctm = localtime(&t)))
- --- 25,31 ----
- time_t dostime(t)
- time_t t;
- {
- ! time_t time, date;
- struct tm *ctm;
-
- if (!(ctm = localtime(&t)))
- ***************
- *** 44,50 ****
- int fh;
- time_t settime;
- unsigned long dtime; /* dos time equivalent */
- ! char filename[FILENAME_MAX];
-
- if (tset)
- settime = tset->modtime;
- --- 44,50 ----
- int fh;
- time_t settime;
- unsigned long dtime; /* dos time equivalent */
- ! char filename[PATH_MAX];
-
- if (tset)
- settime = tset->modtime;
-